Which kind of encoding you are using ? When I try to send data from anyother client it doesn't decode it correctly .
Code:
Try
Dim str As String = Me.Text
Dim sw As IO.StreamWriter
Try
sw = New IO.StreamWriter(client.GetStream)
sw.Write(str)
sw.Flush()
Catch ex As Exception
End Try
Catch ex As Exception
End Try
I was able to decode the sent info of your server to my client by trying the encode methode. But I dont know how encode text and sent it in the right format to allow your server to read it . There is the code I used to read the previous information sent to my client.
Code:
Private Sub DoRead(ByVal ar As System.IAsyncResult)
Dim totalRead As Integer
Try
totalRead = client.GetStream.EndRead(ar) 'Ends the reading and returns the number of bytes read.
Catch ex As Exception
'The underlying socket have probably been closed OR an error has occured whilst trying to access it, either way, this is where you should remove close all eventuall connections 'to this client and remove it from the list of connected clients.
End Try
If totalRead > 0 Then
'the readBuffer array will contain everything read from the client
Dim receivedString As String = System.Text.Encoding.Unicode.GetString(readBuffer, 0, totalRead)
MessageReceived(receivedString)
End If
Try
client.GetStream.BeginRead(readBuffer, 0, BYTES_TO_READ, AddressOf DoRead, Nothing) 'Begin the reading again.
Catch ex As Exception
'The underlying socket have probably been closed OR an error has occured whilst trying to access it, either way, this is where you should remove close all eventuall connections 'to this client and remove it from the list of connected clients.
End Try
End Sub