I am using an ElSSLSocket from C#. This is a SecureBlackBox socket. SecureBlackBox is a third party library to handle secure sockets.
I can see that the ElSSLSocket object has a property called 'Socket' so the underlying socket is a normal .NET socket.
My question, is there some kind of event that I can subscribe to so that I can see when the socket disconnects uncleanly? I have a client server connection which often will disconnect. It is hard to see if it is the client or the server, and hard to see the actual cause.
I am pretty sure that there is some logic problems in the application, i.e. this is not caused by network outages or anything like that.
I should also let you know that the disconnections I get are this error,
SocketException - An existing connection was forcibly closed by the remote host
ErrorCode - 10054
If there was any way that I could actually find the cause of that?
Detecting half-open connections is one of the classic socket programming scenarios. The Socket.Connected
property is completely useless, and Socket.Poll
does not work for every situation. It's best to actually send a "heartbeat" message every few seconds.
10054 is one of the common errors. It means the connection has been lost (not cleanly closed). It can be caused by the remote computer shutting down, the remote process exiting, or even an intermediate router being rebooted.
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