| Error Handling | ||
|
Typically an error is indicated when a SocketTools function either returns a value of zero (false) or -1. When an error occurs in one of the libraries, the GetLastError function can be used to obtain the error code. The GetLastError function returns a unsigned 32-bit integer value that is unique to each thread in a given application. Each library also has it's own private function which will return the last error code for the current thread. For example, the File Transfer Protocol library has a function called FtpGetLastError. SocketTools error codes conform to the standard format used by Windows:
Each of the SocketTools error codes has a matching constant, defined in the header files or modules provided for your programming language. These constants should always be used for comparison against the value returned by the GetLastError function. For each error code, there is a matching description of the error which can be used by the application. Applications may choose to use these error descriptions when displaying a message box to a user or for internal logging purposes. To retrieve the description of the error, the FormatMessage function can be used. Each library also has its own private function to return an error description which may be easier to use. For example, the File Transfer Protocol library has a function called FtpGetErrorString, the Hypertext Transfer Protocol library has a function called HttpGetErrorString and so on. |
||
|
Copyright © 2008 Catalyst Development Corporation. All rights reserved. |
||