DalexL
Active member
- Joined
- Jul 3, 2010
- Messages
- 34
- Programming Experience
- 3-5
I had a thread in the forum for help sending a stream of bytes over. In return, I was shown something similar to the following code:
I modified this code to be used with the receiving sub:
The receiving one works (most of the time, depending on how I tweak it), but even if it does get the stream, it never stops trying to read it.
I tried sending it a packet that could be translated to "ChunksDone" but when converting the last packet to a string, it returned gibberish instead of a string that I could compare to my constant string "ChunksDone".
Any help would be appreciated...
VB.NET:
Public Shared Sub sendStreamedBytePackets(ByVal srmSource As Stream, ByVal client As TcpClient)
Dim buffer(BUFFER_LENGTH - 1) As Byte
Dim byteCount As Integer = srmSource.Read(buffer, 0, BUFFER_LENGTH)
Dim srmTarget = client.GetStream
Do Until byteCount = 0
srmTarget.Write(buffer, 0, byteCount)
byteCount = srmSource.Read(buffer, 0, BUFFER_LENGTH)
Loop
'sendStringPackets("ChunksDone", client)
End Sub
I modified this code to be used with the receiving sub:
VB.NET:
Public Shared Sub getStreamedBytePackets(ByVal client As TcpClient, ByVal srmTarget As Stream)
Dim buffer(BUFFER_LENGTH - 1) As Byte
Dim srmSource = client.GetStream
Dim byteCount As Integer = -1 '= srmSource.Read(buffer, 0, BUFFER_LENGTH)
Do Until byteCount = 0
byteCount = srmSource.Read(buffer, 0, BUFFER_LENGTH)
srmTarget.Write(buffer, 0, byteCount)
Loop
End Sub
The receiving one works (most of the time, depending on how I tweak it), but even if it does get the stream, it never stops trying to read it.
I tried sending it a packet that could be translated to "ChunksDone" but when converting the last packet to a string, it returned gibberish instead of a string that I could compare to my constant string "ChunksDone".
Any help would be appreciated...