Hi people, i need somoe help reading data from sockets!
i need to send a long string containing information, the problem is when server "receives" the string, it comes divide into 2 parts, so how i read the whole string sended to the end, and not splited into 2 pieces? here is the code that i have to read:
and here is the send:
thanks for the help
i need to send a long string containing information, the problem is when server "receives" the string, it comes divide into 2 parts, so how i read the whole string sended to the end, and not splited into 2 pieces? here is the code that i have to read:
VB.NET:
Dim endfile As String = "<EOF>"
Dim BytesRead As Integer
Dim strMessage As String
Try
SyncLock client.GetStream
BytesRead = client.GetStream.EndRead(ar)
End SyncLock
strMessage = Encoding.ASCII.GetString(readBuffer, 0, BytesRead - 1)
RaiseEvent LineReceived(Me, strMessage.Replace(endfile, ""))
SyncLock client.GetStream
client.GetStream.BeginRead(readBuffer, 0, READ_BUFFER_SIZE, AddressOf StreamReceiver, Nothing)
End SyncLock
Catch e As Exception
End Try
End Sub
and here is the send:
VB.NET:
Dim writer As New IO.StreamWriter(client.GetStream)
writer.Write(data + endfile & vbCr)
writer.Flush()
thanks for the help