Hi,
I have a C# TCP/IP host which talks to a piece of proprietary
hardware.
When certain events occur on the hardware it closes it's TCP/IP
connection which results in [FIN, ACK] being sent to the TCP/IP stack
on my host. However, the hardware will not proceed to its next state
until it gets a [FIN] back.
My problem is that I can't see a way in my C# program of determining
that the remote client closed its connection.
I read the data in a loop with this piece of code.
if (_Socket.Available > 0) {
int read = _Socket.Receive(dataBytes, _Socket.Available,
SocketFlags.None);
....
}
where _Socket is my open socket connected to the hardware.
Is there anything I can do there to spot the fact that the remote
client has closed the connection, so that I can close my end of the
connection (which will send the [FIN] which the client expects)?
Alternatively, is there a way to configure the socket so that it
automatically closes when it receives [FIN] from the client?
Many thanks for any help you can offer.
Regards,
Bob.