Example #1
0
bool WinSockDll::Init(){
	#if PLATFORM == PLATFORM_WINDOWS
		int res = WSAStartup(MAKEWORD(2, 1), &_wsaData);
		if(res==0)return true;
		Error error;
		switch(res){
		case WSASYSNOTREADY:
			error.HandleError(Log, "The underlying network subsystem is not ready for network communication.");
			break;
		case WSAVERNOTSUPPORTED:
			error.HandleError(Log, "The version of Windows Sockets support requested is not provided by this particular Windows Sockets implementation.");
			break;
		case WSAEINPROGRESS:
			error.HandleError(Log, "A blocking Windows Sockets 1.1 operation is in progress");
			break;
		case WSAEPROCLIM:
			error.HandleError(Log, "A limit on the number of tasks supported by the Windows Sockets implementation has been reached.");
			break;
		case WSAEFAULT:
			error.HandleError(Log, "The lpWSAData parameter is not a valid pointer.");
			break;
		}
		return false;
    #else
    return true;
    #endif
};
Example #2
0
bool WinSockDll::Cleanup(){
	#if PLATFORM == PLATFORM_WINDOWS
		int res = WSACleanup();
		if(res==0)return true;
		Error error;
		switch(res){
		case WSANOTINITIALISED:
			error.HandleError(Log, "A successful WSAStartup call must occur before using this function.");
			break;
		case WSAENETDOWN:
			error.HandleError(Log, "The network subsystem has failed.");
			break;
		case WSAEINPROGRESS:
			error.HandleError(Log, "A blocking Winsock call is in progress, or the service provider is still processing a callback function.");
			break;
		}
		return false;
	#endif
};