how can I check if a socket connection is still alive from tcp client?

K

klwizzard

Dear newsgroup,

I want to check from a tcp client if a socket connection to a server is
available or the server is down.
I'm using a TcpClient to handle the connection.
I'm using the asynchron communication with a stream.
For the test I'm using the Client property of the TcpClient.

I've test the sample in the msdn from the Socket.Connected property but it
don't work correct in my code.

My questions are:
1st Whats the easiest way to handle my problem?
2nd Where can I found any further information about this?
3rd Exist anywhere a complete sample for this?

Thanks for your time and any kind of help.

Best regards
Detlev
 
J

Jeroen Mostert

klwizzard said:
I want to check from a tcp client if a socket connection to a server is
available or the server is down.

Simply use it. If it fails, the connection is down.

The nature of TCP/IP permits the connection to be "not there" as long as no
data is being exchanged, so there is no (reliable) property that will tell
you when the connection is available. Some circumstances allow detection of
a down connection without data exchange (network cable unplugged and
suchlike) but these are the exception rather than the rule.

To detect a stale connection within a certain time frame, you should send
data periodically. What data would be appropriate depends on the protocol.
 
K

klwizzard

Hello Jeroen,

many thanks for your response.
I worry, that this the way to do this.

Best regards
Detlev
 
K

klwizzard

Hello Peter,

I worry that the way ist to solve my problem.
Not the exactness of Jeroen's reply.
I hoped that there is a solution which I could not find out.
So I hope I could explain my "I worry".

Best regards
Detlev
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top