What event is raised when a .Net Sockets Keep Alive does not receive an ackowledgement?
I have configured my C# .Net socket using
m_clientSocket.SetSocketOption(SocketOptionLevel.Socket, SocketOptionName.KeepAlive, Convert.ToInt32(True))
m_clientSocket.IOControl(IOControlCode.KeepAliveValues, SIO_KEEPALIVE_VALS, result)
My settings are to send every 30 seconds and then send every 10 seconds when the first acknowledgement is not received.
I can see keep alive and keep alive ack flags being sent and received to my server when the connection is up.
When the connection is broken I can see my keep alive being sent and no acknowledgement being received. I can see that the keep alives being sent have changed their behaviour in line with my settings, i.e. they are being sent every 10 seconds as opposed to every 30 seconds.
I was expecting some sort of event to fire so that I can respond to the break (i.e. shutdown the socket and then start trying to recycle it).
Ca开发者_如何学运维n anybody tell me how to pick up on the fact that the Keep Alives have noticed the connection is broken ?
Thanks Ady
Sockets do not raise events regarding their connectivity state (or anything else for that matter). To detect failure, you need to do either a Send or Receive operation.
You should also get indication of failure if you poll the socket periodically. There is an example for that here: Instantly detect client disconnection from server socket
精彩评论