Appendix Handling Socket Errors

Most of the socket constructors and methods in the .NET library can throw a Socket-Exception. Unlike some other exception classes in the .NET library, the SocketException class is fairly generic and requires some additional work to find out what type of error occurred. SocketException contains two useful properties, Message and ErrorCode. The Message property contains a human-readable error message. The ErrorCode property contains a WinSock error code from the underlying implementation, and can be used to trap and handle very specific error conditions.

Table A.1 lists the WinSock error codes that can be retrieved from the ErrorCode property. The Error Name field is the header constant used with WinSock. These ...

Get TCP/IP Sockets in C# now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.