Methods are a bit different in that errors can be handled in one of two ways. By default, when a method is called it will return a value that indicates success or failure. For those methods that return boolean values, a value of true indicates success and a value of false indicates failure. For methods that return numeric values, such as the Read and Write methods, a return value of zero or greater indicates success, and a return value of -1 indicates failure.
If you prefer to handle exceptions, rather than check return values for each method call, SocketTools has a property called ThrowError. If this property is set to true, when a method fails it will throw an exception that must be caught by the application. In that case, if an error occurs without there being an exception handler in place, the application will typically terminate. The ErrorCode property of the exception class will specify the error that generated the exception. Refer to the Technical Reference for more information about the exception class specific to the class library being used.
To determine the error code for the last error generated by that instance of the class, use the LastError property. To display a description of the error to the user, the LastErrorString property will can be used. This returns a string that describes the error which corresponds to the value of the LastError property. It is permitted to set the LastError property to a value of zero in order to clear the last error code. It is important to note that the last error code only has meaning if the previous method call indicates the operation has failed. If the previous operation was successful, the value of the last error code will be undefined and should not be used.