Is it ok to Swallow SocketExceptions in some situations? (C#)

Posted by NoPyGod on Stack Overflow See other posts from Stack Overflow or by NoPyGod
Published on 2010-05-14T08:22:08Z Indexed on 2010/05/14 8:24 UTC
Read the original article Hit count: 293

Filed under:
|
|

Let's say I've programmed an application which connects to a server using the Socket Class (TCP). If I encounter a SocketException while reading or writing, then obviously I have to do go ahead and run a disconnection routine to change the application's state to Disconnected.

But what if I've started to Disconnect, and while I'm cleaning up, a SocketException occurs?

The SocketException doesn't really mean anything to me, as I was going to shutdown the socket myself anyway.. so is it ok to swallow it?

I really want to know what the best practice for this situation is.

© Stack Overflow or respective owner

Related posts about socket

Related posts about shutdown