File Sending with IrDA (PPC to Others) with VB.NET
Posted on 2004-09-08
I am currenting using "OBEX" as the servicename to send a image from a PPC to Any other device, e.g PC thru IrDA.
Current my code allows me to send the file, but it doesn't appear anywhere in my PC. (It only appears to send, not sure if it really did.)
Also, while sometimes it's ok to send 1 file, it crashes when i try to send another.
Error given was
"An unhandled exception of type 'System.IO.IOException' occurred in System.dll, Additional information: Unable to write data to the transport connection."
My IrDA Data transfer code is as followed...
Private Function ir_senddata() As Boolean
Dim irClient As New IrDAClient
Dim irServiceName As String = "OBEX"
Dim buffersize As Integer = 65535
Dim fs As Stream
fs = New FileStream("\TEST.JPG", FileMode.Open)
Catch exFile As Exception
global.prompt(global.errorcode(5) & exFile.ToString) : Return False
irClient = New IrDAClient(irServiceName)
Catch exS As SocketException
global.prompt(global.errorcode(6) & exS.Message) : Return False
Dim baseStream As Stream = irClient.GetStream()
Dim length As Byte() = BitConverter.GetBytes(Fix(fs.Length))
baseStream.Write(length, 0, length.Length)
Dim buffer(buffersize) As Byte
Dim fileLength As Integer = CInt(fs.Length)
While fileLength > 0
Dim numRead As Integer = fs.Read(buffer, 0, buffer.Length)
baseStream.Write(buffer, 0, numRead)
fileLength -= numRead
Can anyone divert me to a really good example code of file/data sending with IrDA from PPC in VB.NET? And what caused the error? (And, any Bluetooth codes as well?:))