kurt69
Well-known member
Hi, I just started writing the lobby section of my game where users can chat, view information about game settings and etc. I've tested this over the internet and through a network and it does connect perfectly however the data that is sent is changed. Have a look at this picture, I'm just running my application twice, having one listen and the other connect (the host is on the top and the client on the bottom).

No matter what the chatters name is, it has those square things to the end of it on the other end of the connection. It is also supposed to say "Kurt has connected" on the host and "Welcome to Kurt's lobby." on the client, text is being cut off after the data from the stream? Also I can't seem to work out how to send/receive any data after the initial connection.
Code to send data when command button is pressed: (doesn't work)
Code I tried to constantly check and get data from the network stream: (doesn't work)
The timer is set to 50ms.
So what am I doing wrong, how can I make this fully work?

No matter what the chatters name is, it has those square things to the end of it on the other end of the connection. It is also supposed to say "Kurt has connected" on the host and "Welcome to Kurt's lobby." on the client, text is being cut off after the data from the stream? Also I can't seem to work out how to send/receive any data after the initial connection.
Code to send data when command button is pressed: (doesn't work)
VB.NET:
Private Sub btnSend_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnSend.Click
rxtChat.AppendText(Chr(13) & txtChat.Text)
Dim chatData As String = sharedVariables.charName & ": " & txtChat.Text
Dim chatBytes As [Byte]() = Encoding.ASCII.GetBytes(chatData)
networkStream.Write(chatBytes, 0, chatBytes.Length)
txtChat.Text = "Please type your message here..."
End Sub
VB.NET:
Private Sub connectTimer_Tick(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles connectTimer.Tick
If networkStream.DataAvailable = True Then
Try
Dim bytes(tcpClient.ReceiveBufferSize) As Byte
networkStream.Read(bytes, 0, CInt(tcpClient.ReceiveBufferSize))
' Output the data received from the host to the console.
Dim returndata As String = Encoding.ASCII.GetString(bytes)
rxtChat.AppendText(Chr(13) & returndata)
Catch ex As Exception
rxtChat.AppendText(Chr(13) & ex.ToString)
End Try
End If
End Sub
So what am I doing wrong, how can I make this fully work?
Last edited: