Skip to main content
GameDev.net gamedev.net
🔒 Locked

Catching Specific Socket Exceptions [CS/C# 2005]

Started by Shaitan00 Oct 10, 2006 at 5:43 PM 0 replies 950+ views
Original Post
Shaitan00
Shaitan00
I have a main application [frmMain] that launches threads (tcp listeners) - at a certain point I want to STOP these threads (which will close my listener, sockets, and abort the thread - this all works fine). Thing is it also launches 2 exceptions: - SocketException: A blocking operation was interrupted by a call to WSACancelBlockingCall - ThreadAbortException: Thread was being aborted. This is my current CATCH-phase code: catch (SocketException sex) { Log.Trace("Socket Exception: " + sex); } catch (Exception ex) { Log.Trace("General Exception: " + ex); } Now I am pretty sure I can catch the Thread Abort Exception using: "catch (ThreadAbortException) {}" first on the list... But I have no clue how to "catch" the specific Socket Exception ("A blocking operation was interrupted by a call to WSACancelBlockingCall") so that it does NOT log as an exception (it is perfectly fine that it was interrupted by me when aborting the thread), not as simple as ThreadAbort... How can I determine if this is NOT an exception I want to log? Any ideas, hints, and help would be greatly appreciated, thanks

Topic Locked

This topic has been locked by a moderator. New replies are not allowed.

Sign in to reply to this topic.