comparison libnnchat.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 6e47426efb6a
comparison
equal deleted inserted replaced
90:1e0bf7b4fd41 91:acfc4b4bc180
87 closesocket(sock); 87 closesocket(sock);
88 #else 88 #else
89 close(sock); 89 close(sock);
90 #endif 90 #endif
91 } 91 }
92 }
93
94
95 BOOL initNetwork(void)
96 {
97 #ifdef __WIN32
98 /* Initialize WinSock, if needed */
99 WSADATA wsaData;
100 int err = WSAStartup(0x0101, &wsaData);
101 if (err != 0) {
102 THERR("Could not initialize WinSock library (err=%d).\n", err);
103 return FALSE;
104 }
105 #endif
106 return TRUE;
107 }
108
109
110 void closeNetwork(void)
111 {
112 #ifdef __WIN32
113 WSACleanup();
114 #endif
92 } 115 }
93 116
94 117
95 BOOL sendToSocket(const int sock, char *buf, const size_t bufLen) 118 BOOL sendToSocket(const int sock, char *buf, const size_t bufLen)
96 { 119 {