Exemple #1
0
static bool sk_startup(int hi, int lo)
{
    WORD winsock_ver;

    winsock_ver = MAKEWORD(hi, lo);

    if (p_WSAStartup(winsock_ver, &wsadata)) {
	return false;
    }

    if (LOBYTE(wsadata.wVersion) != LOBYTE(winsock_ver)) {
	return false;
    }

    return true;
}
Exemple #2
0
int sk_startup(int hi, int lo)
{
    WORD winsock_ver;

    winsock_ver = MAKEWORD(hi, lo);

    if (p_WSAStartup(winsock_ver, &wsadata)) {
	return FALSE;
    }

    if (LOBYTE(wsadata.wVersion) != LOBYTE(winsock_ver)) {
	return FALSE;
    }

#ifdef NET_SETUP_DIAGNOSTICS
    {
	char buf[80];
	sprintf(buf, "Using WinSock %d.%d", hi, lo);
	logevent(NULL, buf);
    }
#endif
    return TRUE;
}
Exemple #3
0
void sk_init(void)
{
    WORD winsock_ver;
    WSADATA wsadata;

    winsock_ver = MAKEWORD(2, 0);
    winsock_module = LoadLibrary("WS2_32.DLL");
    if (!winsock_module) {
	winsock_module = LoadLibrary("WSOCK32.DLL");
	winsock_ver = MAKEWORD(1, 1);
    }
    if (!winsock_module)
	fatalbox("Unable to load any WinSock library");

#ifndef NO_IPV6
    wship6_module = LoadLibrary("wship6.dll");
    if (wship6_module) {
	GET_WINSOCK_FUNCTION(wship6_module, getaddrinfo);
	GET_WINSOCK_FUNCTION(wship6_module, freeaddrinfo);
	GET_WINSOCK_FUNCTION(wship6_module, getnameinfo);
    }
#endif

    GET_WINSOCK_FUNCTION(winsock_module, WSAAsyncSelect);
    GET_WINSOCK_FUNCTION(winsock_module, WSAEventSelect);
    GET_WINSOCK_FUNCTION(winsock_module, select);
    GET_WINSOCK_FUNCTION(winsock_module, WSAGetLastError);
    GET_WINSOCK_FUNCTION(winsock_module, WSAEnumNetworkEvents);
    GET_WINSOCK_FUNCTION(winsock_module, WSAStartup);
    GET_WINSOCK_FUNCTION(winsock_module, WSACleanup);
    GET_WINSOCK_FUNCTION(winsock_module, closesocket);
    GET_WINSOCK_FUNCTION(winsock_module, ntohl);
    GET_WINSOCK_FUNCTION(winsock_module, htonl);
    GET_WINSOCK_FUNCTION(winsock_module, htons);
    GET_WINSOCK_FUNCTION(winsock_module, ntohs);
    GET_WINSOCK_FUNCTION(winsock_module, gethostbyname);
    GET_WINSOCK_FUNCTION(winsock_module, getservbyname);
    GET_WINSOCK_FUNCTION(winsock_module, inet_addr);
    GET_WINSOCK_FUNCTION(winsock_module, inet_ntoa);
    GET_WINSOCK_FUNCTION(winsock_module, connect);
    GET_WINSOCK_FUNCTION(winsock_module, bind);
    GET_WINSOCK_FUNCTION(winsock_module, setsockopt);
    GET_WINSOCK_FUNCTION(winsock_module, socket);
    GET_WINSOCK_FUNCTION(winsock_module, listen);
    GET_WINSOCK_FUNCTION(winsock_module, send);
    GET_WINSOCK_FUNCTION(winsock_module, ioctlsocket);
    GET_WINSOCK_FUNCTION(winsock_module, accept);
    GET_WINSOCK_FUNCTION(winsock_module, recv);
    GET_WINSOCK_FUNCTION(winsock_module, WSAIoctl);

    if (p_WSAStartup(winsock_ver, &wsadata)) {
	fatalbox("Unable to initialise WinSock");
    }
    if (LOBYTE(wsadata.wVersion) != LOBYTE(winsock_ver)) {
	p_WSACleanup();
	fatalbox("WinSock version is incompatible with %d.%d",
		 LOBYTE(winsock_ver), HIBYTE(winsock_ver));
    }

    sktree = newtree234(cmpfortree);
}