TCP listener - check for connection status

M

Markgoldin

tcpl = new TcpListener(ipe);
TcpClient tcpc = tcpl.AcceptTcpClient();
while (true)
{
// get data
while (true)
{
// if contidion met break;
}
}

How can I check if a client has been disconnected from the listener?
I want to do that in order to stop the outer while loop.

Thanks for help.
 
W

William Stacey [C# MVP]

Good answer. When you think about it, it would not even be possible without
some kind of keepalive because your never going to get any back channel
notification that the host is down or a link was broken until you actually
try to send a packet. Unless your waiting on some push notification deal, a
keepalive is not desired anyway.

--william
 

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