TCP Client detects TCP Server?

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

I want my TCP client to be able to to tell if there is a TCP Server running
at the specified IP address and port number without creating exceptions,
because this code will be put in an infinite loop that will keep checking to
detect when the Server is up. How can I do that?

I wrote TCP client and TCP server applications using TCPClient and
TCPListner objects.

Currently at the Client side, I create a NetworkStream and use the GetStream
to establish a communication channel between the client and the server. The
problem with this approach is that the client will hang on until a connection
is found or until it times out.
 
Currently at the Client side, I create a NetworkStream and use the
GetStream to establish a communication channel between the client and
the server. The problem with this approach is that the client will
hang on until a connection is found or until it times out.

You should open the connection in it's own thread... or via async calls.

This will allow your GUI to continue without hanging.
 
I never mentioned a GUI interface. In fact I don't have one, since I'm using
Windows Services. I was hoping to get something similar to pinging the Server
and return a True or False to determine if the server was up or not, instead
of making exceptions in my loop!
 
I never mentioned a GUI interface. In fact I don't have one, since I'm
using Windows Services. I was hoping to get something similar to
pinging the Server and return a True or False to determine if the
server was up or not, instead of making exceptions in my loop!


I don't think the built in TCP classes support this feature.
 
Back
Top