Hello everyone, i need some help figuring out how to receive an image via UDP, i have an application written in visual Basic 2008 running in my computer, i'm actually trying to send a picture and i'm trying to receive on my android phone.
this is the code i have to send the picture from my computer
what i need is a way to receive the bytes on my phone and reconstruct the image somehow, i can send a text file but i only receive a portion of the text not all of it, i'm using the
sub can anyone point me in the right direction please?
thanks,
Walter
this is the code i have to send the picture from my computer
B4X:
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
trasmiUdpHost.Connect(GLOIP, GLOINTPORT)
Dim strReturnData As String
Dim path As String = "C:\Users\florew1\Pictures\Reyes Creek pictures\Reyes Creek pictures 008.jpg"
Dim sr As FileStream = New FileStream(path, FileMode.Open, FileAccess.Read)
Dim bytes() As Byte = New Byte((sr.Length) - 1) {}
Dim numBytesToRead As Integer = CType(sr.Length, Integer)
Dim numBytesRead As Integer = 0
While (numBytesToRead > 0)
' Read may return anything from 0 to numBytesToRead.
Dim n As Integer = sr.Read(bytes, numBytesRead, _
numBytesToRead)
' Break when the end of the file is reached.
strReturnData = System.Text.Encoding.Unicode.GetString(bytes) 'I know this part i need to change so that it send the bytes instead of a string
pRet = trasmiUdpHost.Send(bytes, bytes.Length) 'this is the part that sends the bytes read from the picture and it sends it via UDP
If (n = 0) Then
Exit While
End If
numBytesRead = (numBytesRead + n)
numBytesToRead = (numBytesToRead - n)
End While
numBytesToRead = bytes.Length
End Sub
what i need is a way to receive the bytes on my phone and reconstruct the image somehow, i can send a text file but i only receive a portion of the text not all of it, i'm using the
B4X:
Sub UDP_PacketArrived (Packet As UDPPacket)
thanks,
Walter
Last edited: