Home All Groups Group Topic Archive Search About

TCP Client detects TCP Server?

Author
26 May 2006 7:48 PM
Amjad
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.

Author
27 May 2006 2:43 AM
Spam Catcher
=?Utf-8?B?QW1qYWQ=?= <Am***@discussions.microsoft.com> wrote in
news:D2099DB0-8166-4835-87A2-3F38C8C802C2@microsoft.com:

> 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.
Author
29 May 2006 12:54 PM
Amjad
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!

Show quoteHide quote
"Spam Catcher" wrote:

> =?Utf-8?B?QW1qYWQ=?= <Am***@discussions.microsoft.com> wrote in
> news:D2099DB0-8166-4835-87A2-3F38C8C802C2@microsoft.com:
>
> > 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.
>
Author
29 May 2006 2:22 PM
Spam Catcher
=?Utf-8?B?QW1qYWQ=?= <Am***@discussions.microsoft.com> wrote in
news:4CB9904D-5441-4A54-B6CD-28C906DC4C7A@microsoft.com:

> 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.