I am getting over lapping data while sending and receiving data in a tcp listener I am working on. How does one reset or clear the buffer or bytes so they don't carry over to the next send or receive?
Thanks in advance!
Partial Example:
' Client sends:
TempS = curAdd.ToString & ".............. ............... ............... ............... ............... ............... ............"
' Padding the end of the IP address so I can trim(".") when received because I couldn't trim the free space at the end.
Buffer = System.Text.Enc oding.Default.G etBytes(TempS.T oString)
Client.GetStrea m().Write(Buffe r, 0, Buffer.Length)
' The Server Receives:
While Not StopListener
If CurSocket.Avail able > 0 Then
' 1. Receive IP Address from client:
Bytes = CurSocket.Recei ve(Buffer, Buffer.Length, 0)
SyncLock CurThread
clientV = (System.Text.En coding.Default. GetString(Buffe r)).ToString
clientV = clientV.Trim(". ")
Buffer.Clear(Bu ffer, Buffer.Length, 0)
On the next send / receive I am getting leftover ........... in the string.
THANKS!
Thanks in advance!
Partial Example:
' Client sends:
TempS = curAdd.ToString & ".............. ............... ............... ............... ............... ............... ............"
' Padding the end of the IP address so I can trim(".") when received because I couldn't trim the free space at the end.
Buffer = System.Text.Enc oding.Default.G etBytes(TempS.T oString)
Client.GetStrea m().Write(Buffe r, 0, Buffer.Length)
' The Server Receives:
While Not StopListener
If CurSocket.Avail able > 0 Then
' 1. Receive IP Address from client:
Bytes = CurSocket.Recei ve(Buffer, Buffer.Length, 0)
SyncLock CurThread
clientV = (System.Text.En coding.Default. GetString(Buffe r)).ToString
clientV = clientV.Trim(". ")
Buffer.Clear(Bu ffer, Buffer.Length, 0)
On the next send / receive I am getting leftover ........... in the string.
THANKS!
Comment