Hi. I'm doing an application to transfer files from one peer to another. I want to know when a remote peer disconnect, so the peer (local) can handle this event.
It seems that after certain time the condition I'm using to see if the connection is active (wich I got from internet) returns false, but sockets are still connected. If I don't test for this condition, then all works normally.
The function I'm using to see if the connection is active is:
VB Code:
Protected Overridable Sub Poll() If [B]m_socket.Poll(10000, SelectMode.SelectRead) And m_socket.Available = 0[/B] Then m_state = TRANSFER_STATE.REMOTECANCELED Close() MyBase.Abort() RaiseEvent TransferAborted() End If End Sub
The important thing here is the if condition of course. I've also tested with 1000 microseconds instead of 10000, and had the same result.
This Poll() function is executed every second.
Any idea how to get a value that I can trust on it to know when a connection was closed?
Regards.




Reply With Quote