Newbie question here.. Just trying to be sure here..
This is not a HTTP Keep-Alive question.
Is there a way to make sure a socket gets closed() after a certain amount of time.
Why i'm asking this because if I just close socket right away.. the client may not receive the packet to indicate like incorrect password etc..
Is there any timeout like built in command inside Socket?
I'm trying to avoid building a timer or event to close it off thinking of a alternate solution
I never tried it myself, but there is LingerOption.
Take a look at Socket.LingerState Property.
This property controls the length of time that a connection-oriented connection will remain open after a call to Close when data remains to be sent. When you call methods to send data to a peer, this data is placed in the outgoing network buffer. This property can be used to ensure that this data is sent to the remote host before the Close method drops the connection.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With