K
Kenneth H. Young
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.Encoding.Default.GetBytes(TempS.ToString)
Client.GetStream().Write(Buffer, 0, Buffer.Length)
' The Server Receives:
While Not StopListener
If CurSocket.Available > 0 Then
' 1. Receive IP Address from client:
Bytes = CurSocket.Receive(Buffer, Buffer.Length, 0)
SyncLock CurThread
clientV = (System.Text.Encoding.Default.GetString(Buffer)).ToString
clientV = clientV.Trim(".")
Buffer.Clear(Buffer, 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.Encoding.Default.GetBytes(TempS.ToString)
Client.GetStream().Write(Buffer, 0, Buffer.Length)
' The Server Receives:
While Not StopListener
If CurSocket.Available > 0 Then
' 1. Receive IP Address from client:
Bytes = CurSocket.Receive(Buffer, Buffer.Length, 0)
SyncLock CurThread
clientV = (System.Text.Encoding.Default.GetString(Buffer)).ToString
clientV = clientV.Trim(".")
Buffer.Clear(Buffer, Buffer.Length, 0)
On the next send / receive I am getting leftover ........... in the string.
THANKS!