Thanks for the suggest guys, I am going to use the first code which it works well for me. However, please can you help me with if statement as I want to listen to the server to see if the client is connected then display the messagebox.
When I tried this:
if server.Server.Connected = true)
The messagebox doesn't display, so when i tried this:
its still the same, so I don't know which property that I should use.
Here's the current code:
Dim server As TcpListener = Nothing
server = Nothing
Dim port As Int32 = 13000
Dim localAddr As IPAddress = IPAddress.Parse("127.0.0.1")
server = New TcpListener(localAddr, port)
' Start listening for client requests.
Dim clientSocket As New System.Net.Sockets.TcpClient()
If server.Server.Accept() Then
Catch ex As Exception
'reconnect to the server
Any idea what property that I should use if I wish to listen to the server to see if the client is connected?