This pull request addresses issue #105 where established connections were not being properly closed when the unlink command was executed. The issue appears to be in TCPPeer.cs in Stop() where the CancelationTokenSource is cancelled but _sendTask.Wait() never returns which is causing the hang.
This solution is fairly simple and does the following:
Grabs the handle from OnConnect() when a new TCP link is established and stores the value in a new _socketHandle property
When unlink is issued, after the CancelationTokenSource is cancelled, CloseHandle() is called on that handle
Connection is closed, the function returns, and the link is removed
There might be a more eloquent solution by figuring out why the sendTask never returns but figured this is a good starting place for discussion.
This pull request addresses issue #105 where established connections were not being properly closed when the
unlink
command was executed. The issue appears to be in TCPPeer.cs inStop()
where theCancelationTokenSource
is cancelled but_sendTask.Wait()
never returns which is causing the hang.This solution is fairly simple and does the following:
OnConnect()
when a new TCP link is established and stores the value in a new_socketHandle
propertyunlink
is issued, after theCancelationTokenSource
is cancelled, CloseHandle() is called on that handleThere might be a more eloquent solution by figuring out why the sendTask never returns but figured this is a good starting place for discussion.