TCP Client detects TCP Server?

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Amjad

    #1

    TCP Client detects TCP Server?

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

    #2
    Re: TCP Client detects TCP Server?

    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!

    "Spam Catcher" wrote:
    [color=blue]
    > =?Utf-8?B?QW1qYWQ=?= <Amjad@discussi ons.microsoft.c om> wrote in
    > news:D2099DB0-8166-4835-87A2-3F38C8C802C2@mi crosoft.com:
    >[color=green]
    > > 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.
    > >
    > >[/color]
    >
    > You should open the connection in it's own thread... or via async calls.
    >
    > This will allow your GUI to continue without hanging.
    >[/color]

    Comment

    Working...