M
Mike Ruane-Torr
I have a server with an open socket, and I'm doing this:
if (sock.Available > 0)
{
sock.BeginReceive(...)
}
else
{
Thread.Sleep(...)
}
....in a loop, so that I only run BeginReceive() when there is data present
to be received.
Problem: How can I introduce an extra bit of code before the above, which
will tell me whether the client has closed the connection?
I've tried this:
if (!sock.Poll(1,SelectMode.SelectRead))
{
Abort();
}
....but it doesn't seem to work.
If I understand TCP/IP correctly, when the client closes the connection, a
FIN packet is sent. Therefore the information is present in the server
machine SOMEWHERE. So how do I get to it?
if (sock.Available > 0)
{
sock.BeginReceive(...)
}
else
{
Thread.Sleep(...)
}
....in a loop, so that I only run BeginReceive() when there is data present
to be received.
Problem: How can I introduce an extra bit of code before the above, which
will tell me whether the client has closed the connection?
I've tried this:
if (!sock.Poll(1,SelectMode.SelectRead))
{
Abort();
}
....but it doesn't seem to work.
If I understand TCP/IP correctly, when the client closes the connection, a
FIN packet is sent. Therefore the information is present in the server
machine SOMEWHERE. So how do I get to it?