Mercurial > hg > nnchat
diff nnchat.c @ 91:acfc4b4bc180
Create network initialization functions in libnnchat and move Win32/WinSock code there.
author | Matti Hamalainen <ccr@tnsp.org> |
---|---|
date | Thu, 07 May 2009 00:04:37 +0300 |
parents | 1e0bf7b4fd41 |
children | 638f88374e3e |
line wrap: on
line diff
--- a/nnchat.c Wed May 06 23:55:21 2009 +0300 +++ b/nnchat.c Thu May 07 00:04:37 2009 +0300 @@ -563,9 +563,7 @@ exitProg = FALSE, colorSet = FALSE, cursesInit = FALSE, -#if __WIN32 networkInit = FALSE, -#endif insertMode = TRUE; struct timeval tv; fd_set sockfds; @@ -606,18 +604,11 @@ } } -#ifdef __WIN32 - { - /* Initialize WinSock, if needed */ - WSADATA wsaData; - int err = WSAStartup(0x0101, &wsaData); - if (err != 0) { - THERR("Could not initialize WinSock DLL: %d\n", err); - goto err_exit; - } + if (!initNetwork()) { + THERR("Could not initialize network subsystem.\n"); + goto err_exit; + } else networkInit = TRUE; - } -#endif /* Okay ... */ THMSG(1, "Trying to resolve host '%s' ...\n", optServer); @@ -981,10 +972,8 @@ closeConnection(tmpSocket); -#ifdef __WIN32 if (networkInit) - WSACleanup(); -#endif + closeNetwork(); THMSG(1, "Connection terminated.\n");