How do you Check if TcpListener is available?

korae

Member
Joined
Jan 24, 2010
Messages
22
Programming Experience
Beginner
I have this code to connect to my server:

client = New TcpClient(txtIP.Text, txtPort.Text)
client.GetStream.BeginRead(readBuffer, 0, BYTES_TO_READ, AddressOf DoRead, Nothing)
SendMessage("/CONNECT|" & Label25.Text)

How do I check if the TcpListener is available?

I get this error when I run it without a server

"No connection could be made because the target machine actively refused it 127.0.0.1:43000"
 
You just have to TRY, the only way to find out if connection is possible is to try to connect. If connection is not possible exception is thrown. Most sockets operations require exception handling as this is the only way to catch those unexpected problems.
 
Back
Top