I have a server that receives connection requests from clients. This server makes use of the asynchronous Socket.BeginReceive
and Socket.EndReceive
method. The code is pretty similar to the code found here.
In my case, after calling Socket.BeginReceive
I need a timeout such that if the client hangs on to the connection but does not transmit any data at all for a fixed amount of time, I need to terminate the connection.
- How do I go about terminating the connection in this scenario?
- What is the best way of coding a timer?