#include WORD WSASystem::smIsInitialized; WORD WSASystem::smInstanceCount; WSADATA WSASystem::smWSAData; WSASystem::WSASystem(void) { WORD wsaVersion(MAKEWORD(1,1)); ++smInstanceCount; if(1==smInstanceCount) { ::memset(&smWSAData,0,sizeof(smWSAData)); if(!(::WSAStartup(wsaVersion,&smWSAData)))smIsInitialized=TRUE; } } String WSASystem::getLastError(void)const { switch(::WSAGetLastError()) { case WSANOTINITIALISED : return "WSANOTINITIALISED : A successful WSAStartup must occur before using this function."; case WSAENETDOWN : return "WSAENETDOWN : The network subsystem has failed. "; case WSAEFAULT : return "WSAEFAULT : The buf or from parameters are not part of the user address space, or the fromlen parameter is too small to accommodate the peer address."; case WSAEINTR : return "WSAEINTR : The (blocking) call was canceled through WSACancelBlockingCall. "; case WSAEINPROGRESS : return "WSAEINPROGRESS : A blocking Windows Sockets 1.1 call is in progress, or the service provider is still processing a callback function. "; case WSAEINVAL : return "WSAEINVAL : The socket has not been bound with bind, or an unknown flag was specified, or MSG_OOB was specified for a socket with SO_OOBINLINE enabled, or (for byte stream style sockets only) len was zero or negative. "; case WSAENETRESET : return "WSAENETRESET : The connection has been broken due to the remote host resetting."; case WSAENOTCONN : return "WSAENOTCONN : The socket is not connected (connection-oriented sockets only)."; case WSAENOTSOCK : return "WSAENOTSOCK : The descriptor is not a socket."; case WSAEOPNOTSUPP : return "WSAEOPNOTSUPP : MSG_OOB was specified, but the socket is not stream style such as type SOCK_STREAM, out-of-band data is not supported in the communication domain associated with this socket, or the socket is unidirectional and supports only send operations."; case WSAESHUTDOWN : return "WSAESHUTDOWN : The socket has been shut down; it is not possible to recvfrom on a socket after shutdown has been invoked with how set to SD_RECEIVE or SD_BOTH."; case WSAEWOULDBLOCK : return "WSAEWOULDBLOCK : The socket is marked as nonblocking and the recvfrom operation would block."; case WSAEMSGSIZE : return "WSAEMSGSIZE : The message was too large to fit into the specified buffer and was truncated."; case WSAECONNABORTED : return "WSAECONNABORTED : The virtual circuit was terminated due to a time-out or other failure. The application should close the socket as it is no longer usable."; case WSAETIMEDOUT : return "WSAETIMEDOUT : The connection has been dropped, because of a network failure or because the system on the other end went down without notice."; case WSAECONNRESET : return "The virtual circuit was reset by the remote side executing a “hard” or “abortive” close. The application should close the socket as it is no longer usable. On a UDP datagram socket this error would indicate that a previous send operation resulted in an ICMP \"Port Unreachable\" message."; case WSAEADDRINUSE : return "The specified address is already in use. (See the SO_REUSEADDR socket option under setsockopt.)"; default : return "WSADATA.CPP: Unknown socket error"; } }