Hey, I'm trying to send an image over a connection using sockets. As far as I know I'm sending it correctly from the client:

Code:
    Public Sub TransferData(ByVal FromStream As IO.Stream, ByVal BufferSize As Integer)
        Dim buffer(BufferSize - 1) As Byte
        Dim ToStream As IO.Stream = mobjClient.GetStream
        Do While True
            Dim bytesRead As Integer = FromStream.Read(buffer, 0, buffer.Length)
            If bytesRead = 0 Then Exit Do
            ToStream.Write(buffer, 0, bytesRead)
        Loop

    End Sub


Dim spath As String = "c:\screen.gif"
Dim sfilestrean As FileStream
Dim sfilestream = New FileStream(spath, FileMode.Open, FileAccess.ReadWrite)

TransferData(sfilestream, 1024)
The server does receive the data. But I'm trying to figure out how to put it all back together on the other end.

I send start and end messages like so: "Image" [image data] "End Image".

In the server I have a sub that gets the data.. when receiving the message "Image" it sets a variable (receivingImage = True) and "End Image" sets it to False.

So on this sub, if receivingImage = True I guess I need to put the received bytes into an array so I have:
Code:
Dim imagetmp(1024) As Byte
        If receivingScreen = True Then
            mobjClient.GetStream.Read(imagetmp, imagetmp.Count, CInt(mobjClient.ReceiveBufferSize))
        End If
Which is probably massively incorrect. I've never done anything like this, so some help would be great

Cheers