--- projects/libukcprog/src/ip.c 2003/03/29 16:30:33 1.1 +++ projects/libukcprog/src/ip.c 2005/09/24 13:31:30 1.2 @@ -16,9 +16,13 @@ char ukcprog_ip_sccsid[] = "$Id: ip.c,v 1.7 1995/12/20 #else #include #endif +#ifndef WIN32 #include #include #include +#else +#include +#endif #include #include @@ -41,13 +45,22 @@ struct in_addr *p_addr; char c; if (sscanf(hostname, "%d.%d.%d.%d%c", &b3, &b2, &b1, &b0, &c) == 4) { - unsigned long val; + unsigned long val; - val = (b3 << 24) | (b2 << 16) | (b1 << 8) | b0; - p_addr->s_addr = htonl(val); - return 0; + val = (b3 << 24) | (b2 << 16) | (b1 << 8) | b0; + p_addr->s_addr = htonl(val); + return 0; } +#ifdef WIN32 + /* Init the winsock, because we all love windows */ + WSADATA wsaData; + + if(WSAStartup(MAKEWORD(2,2), &wsaData) != NO_ERROR) { + errf("Unable to init a winsock"); + return -1; + } +#endif if ((h = gethostbyname(hostname)) == NULL) { errf("Can't find address of %s", hostname); return -1; @@ -80,6 +93,16 @@ int *p_port; *p_port = htons(hport); return 0; } + +#ifdef WIN32 + /* Init the winsock, because we all love windows */ + WSADATA wsaData; + + if(WSAStartup(MAKEWORD(2,2), &wsaData) != NO_ERROR) { + errf("Unable to init a winsock"); + return -1; + } +#endif if ((sp = getservbyname(servname, "tcp")) == NULL) { errf("Unknown service `%s'", servname);