<Nightblade> hmm

This commit is contained in:
mpc
2004-07-02 09:54:27 +00:00
committed by zzz
parent f9a96126e1
commit f49be25288
2 changed files with 14 additions and 1 deletions

View File

@@ -40,6 +40,14 @@ Socket::Socket(int type)
{
#ifdef WINSOCK
winsock_startup();
#endif
sock = socket(PF_INET, type, 0);
#ifdef WINSOCK
if (sock == INVALID_SOCKET)
throw Socket_error(sam_winsock_strerror(WSAGetLastError()));
#else
if (sock == -1)
throw Socket_error(strerror(errno));
#endif
}
@@ -62,7 +70,7 @@ void Socket::winsock_startup(void)
WSADATA wsaData;
int rc = WSAStartup(wVersionRequested, &wsaData);
if (rc != 0)
throw Socket_error("WSAStartup() failed (" + winsock_strerror(rc) +")");
throw Socket_error(winsock_strerror(rc));
if (LOBYTE(wsaData.wVersion) != 2 || HIBYTE(wsaData.wVersion) != 2) {
winsock_cleanup();
throw Socket_error("Bad Winsock version");