Asynchronous socket, forced disconnection and reuse?

Whenever I'm writing code that wraps around System.Net.Sockets. Socket, I find myself constantly adding try/catch clauses for SocketException and ObjectDisposedException. In most cases, ObjectDisposedException can simply be ignored, as it, in 99% of cases, indicates that the client has simply disconnected At least that's my impression of how the Socket API in .

NET works. Try adding some exception handlers here and there, and see how it goes. In any case, your Disconnect method should not do more than something like this: public void Disconnect() { try { connectedSocket.

Shutdown(SocketShutdown. Both); } catch (Exception) { // Ignore the exception. The client probably already disconnected.

} connectedSocket.Dispose(); // This is safe; a double dispose will simply be ignored. } I hope that sheds some light on the issue.

Whenever I'm writing code that wraps around System.Net.Sockets. Socket, I find myself constantly adding try/catch clauses for SocketException and ObjectDisposedException. In most cases, ObjectDisposedException can simply be ignored, as it, in 99% of cases, indicates that the client has simply disconnected.At least that's my impression of how the Socket API in .

NET works. Try adding some exception handlers here and there, and see how it goes.In any case, your Disconnect method should not do more than something like this: public void Disconnect() { try { connectedSocket. Shutdown(SocketShutdown.

Both); } catch (Exception) { // Ignore the exception. The client probably already disconnected. } connectedSocket.Dispose(); // This is safe; a double dispose will simply be ignored.

} I hope that sheds some light on the issue...

I cant really gove you an answer,but what I can give you is a way to a solution, that is you have to find the anglde that you relate to or peaks your interest. A good paper is one that people get drawn into because it reaches them ln some way.As for me WW11 to me, I think of the holocaust and the effect it had on the survivors, their families and those who stood by and did nothing until it was too late.

Related Questions