| 81 | // Socket Code |
| 82 | |
| 83 | Socket::Socket(int type, int protocol) throw(SocketException) { |
| 84 | #ifdef WIN32 |
| 85 | if (!initialized) { |
| 86 | WORD wVersionRequested; |
| 87 | WSADATA wsaData; |
| 88 | |
| 89 | wVersionRequested = MAKEWORD(2, 0); // Request WinSock v2.0 |
| 90 | if (WSAStartup(wVersionRequested, &wsaData) != 0) { // Load WinSock DLL |
| 91 | throw SocketException("Unable to load WinSock DLL"); |
| 92 | } |
| 93 | initialized = true; |
| 94 | } |
| 95 | #endif |
| 96 | |
| 97 | // Make a new socket |
| 98 | if ((sockDesc = socket(PF_INET, type, protocol)) < 0) { |
| 99 | throw SocketException("Socket creation failed (socket())", true); |
| 100 | } |
| 101 | } |
| 102 | |
| 103 | Socket::Socket(int sockDesc) { |
| 104 | this->sockDesc = sockDesc; |
nothing calls this directly
no test coverage detected