@
wut12345 Hmm, I looked over the link: as far as I can tell, the object is being disposed and that *is* the problem...
found same issue on stackoverflow:
c# - Proper way to stop listening on a Socket - Stack Overflow
one user says:
2) just Close(0) listening socket which will result in false shot to its callback, if you then look into your listening socket you will see that its state is "closed" and "disposed". This is why calling EndAccept would cause exception. You may just ignore it and do not call EndAccept. Listening socket will go down immediately without timeout.
Calling Socket.Close() "..results in false shot to its callback" - I don't understand why I guess. Not sure how to avoid/fix it.
Looking into it now --> from the stackover link:
"
-1: A socket performing an accept (ie. awaiting new connections) is now the same as a socket connected to a client (where one of Disconnect or Shutdown is the right answer). – Richard Oct 16 '12 at 9:52"
ie. When the callback is called normallly, .Connected will be true, and when it's called as a result of Close(), .Connected will be false. ie
Code:
Private Sub SocketConnectedCallback(ByVal AR As IAsyncResult)
If _serverSocke*****nnected = True Then
_clientSocket = _serverSocket.EndAccept(AR)
End If
End Sub
This avoids the exception, but feels wrong.
Will test soon/update post.
Any comments appreciated.