author | timkelly |
Sun, 06 Dec 2009 20:47:07 -0600 | |
changeset 642 | 20fd716f8eaa |
parent 506 | 44dbbc3220b8 |
permissions | -rw-r--r-- |
60 | 1 |
/* |
2 |
* Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies). |
|
3 |
* All rights reserved. |
|
4 |
* This component and the accompanying materials are made available |
|
5 |
* under the terms of the License "Eclipse Public License v1.0" |
|
6 |
* which accompanies this distribution, and is available |
|
7 |
* at the URL "http://www.eclipse.org/legal/epl-v10.html". |
|
8 |
* |
|
9 |
* Initial Contributors: |
|
10 |
* Nokia Corporation - initial contribution. |
|
11 |
* |
|
12 |
* Contributors: |
|
13 |
* |
|
14 |
* Description: |
|
15 |
* |
|
16 |
*/ |
|
17 |
// TcpComm.cpp: implementation of the CTcpComm class. |
|
18 |
// |
|
19 |
////////////////////////////////////////////////////////////////////// |
|
20 |
||
21 |
#include "stdafx.h" |
|
22 |
#include "TcpComm.h" |
|
23 |
//#include "pn_const.h" |
|
24 |
//#include "OSTConstants.h" |
|
25 |
#include "Connection.h" |
|
26 |
||
27 |
////////////////////////////////////////////////////////////////////// |
|
28 |
// Construction/Destruction |
|
29 |
////////////////////////////////////////////////////////////////////// |
|
30 |
CTcpComm::CTcpComm() |
|
31 |
{ |
|
32 |
#ifdef _DEBUG |
|
33 |
if (gDoLogging) |
|
34 |
{ |
|
366 | 35 |
// FILE* f = fopen("c:\\tcf\\tcpcommlog.txt", "at"); |
36 |
// fprintf(f, "CTcpComm::CTcpComm() (default constructor)\n"); |
|
37 |
// fclose(f); |
|
60 | 38 |
} |
39 |
#endif |
|
40 |
m_socket = INVALID_SOCKET; |
|
41 |
m_timeOut.tv_sec = TIMEOUT_SEC(DEFAULT_SOCKET_TIMEOUT); |
|
42 |
m_timeOut.tv_usec = TIMEOUT_USEC(DEFAULT_SOCKET_TIMEOUT); |
|
43 |
||
44 |
m_hSocketEvent = WSA_INVALID_EVENT; |
|
366 | 45 |
|
60 | 46 |
} |
47 |
||
48 |
CTcpComm::CTcpComm(ConnectData* connectSettings, DWORD connectionId, CBaseProtocol* protocol) |
|
49 |
{ |
|
50 |
#ifdef _DEBUG |
|
51 |
if (gDoLogging) |
|
52 |
{ |
|
366 | 53 |
// FILE* f = fopen("c:\\tcf\\tcpcommlog.txt", "at"); |
54 |
// fprintf(f, "connectSettings=%x connectionId=%d, protocol=%x\n", connectSettings, connectionId, protocol); |
|
55 |
// fclose(f); |
|
60 | 56 |
} |
57 |
#endif |
|
58 |
m_connId = connectionId; |
|
59 |
m_Protocol = protocol; |
|
60 |
||
61 |
m_ConnectSettings = new ConnectData(); |
|
62 |
memcpy(m_ConnectSettings, connectSettings, sizeof(ConnectData)); |
|
63 |
||
64 |
#if (defined(LOG_COMM) || defined(LOG_PROCCOMM)) && defined(_DEBUG) |
|
65 |
if (gDoLogging) |
|
66 |
{ |
|
67 |
m_CommDebugLog = new TCDebugLog("TCF_Comm", connectionId, 2000L); |
|
68 |
m_ProcDebugLog = new TCDebugLog("TCF_CommP", connectionId, 2000L); |
|
69 |
} |
|
70 |
#endif |
|
71 |
m_socket = INVALID_SOCKET; |
|
72 |
m_timeOut.tv_sec = TIMEOUT_SEC(DEFAULT_SOCKET_TIMEOUT); |
|
73 |
m_timeOut.tv_usec = TIMEOUT_USEC(DEFAULT_SOCKET_TIMEOUT); |
|
74 |
||
75 |
m_hSocketEvent = WSA_INVALID_EVENT; |
|
366 | 76 |
|
60 | 77 |
} |
78 |
CTcpComm::~CTcpComm() |
|
79 |
{ |
|
80 |
#ifdef _DEBUG |
|
81 |
if (gDoLogging) |
|
82 |
{ |
|
366 | 83 |
// FILE* f = fopen("c:\\tcf\\tcpcommlog.txt", "at"); |
84 |
// fprintf(f, "CTcpComm::~CTcpComm()\n"); |
|
85 |
// fclose(f); |
|
60 | 86 |
} |
87 |
#endif |
|
88 |
if (IsConnected()) |
|
89 |
{ |
|
366 | 90 |
if (m_socket != INVALID_SOCKET) |
91 |
{ |
|
92 |
shutdown(m_socket, SD_BOTH); |
|
93 |
closesocket(m_socket); |
|
94 |
WSAClose(); |
|
95 |
} |
|
96 |
m_isConnected = false; |
|
60 | 97 |
} |
98 |
if (m_pBuffer) |
|
99 |
delete[] m_pBuffer; |
|
100 |
||
101 |
if (m_hSocketEvent != WSA_INVALID_EVENT) |
|
102 |
WSACloseEvent(m_hSocketEvent); |
|
103 |
||
104 |
} |
|
105 |
||
106 |
//#define USE_EVENTS |
|
107 |
; |
|
108 |
long CTcpComm::OpenPort() |
|
109 |
{ |
|
110 |
COMMLOGOPEN(); |
|
111 |
COMMLOGS("CTcpComm::OpenPort\n"); |
|
112 |
||
113 |
long err = TCAPI_ERR_NONE; |
|
114 |
char* ipAddress = m_ConnectSettings->tcpSettings.ipAddress; |
|
115 |
char* ipPort = m_ConnectSettings->tcpSettings.ipPort; |
|
116 |
// set this to set socket to non-blocking |
|
117 |
// DWORD nonblock = 1; // non-blocking |
|
118 |
DWORD nonblock = 0; // blocking |
|
119 |
||
120 |
COMMLOGA2("CTcpComm::OpenPort ipAddress=%s ipPort=%s\n", ipAddress, ipPort); |
|
121 |
||
366 | 122 |
int wsaErr = 0; |
123 |
wsaErr = WSAInit(); |
|
60 | 124 |
if (wsaErr != 0) |
125 |
{ |
|
126 |
err = TCAPI_ERR_WHILE_CONFIGURING_MEDIA; |
|
127 |
// err = -1; |
|
128 |
} |
|
129 |
else |
|
130 |
{ |
|
131 |
m_socket = socket(AF_INET, SOCK_STREAM, IPPROTO_TCP); |
|
366 | 132 |
COMMLOGA1("CTcpComm::OpenPort socket=%x\n", m_socket); |
60 | 133 |
if (m_socket == INVALID_SOCKET) |
134 |
{ |
|
135 |
m_lastCommError = WSAGetLastError(); |
|
366 | 136 |
WSASetLastError(0); |
137 |
WSAClose(); |
|
60 | 138 |
err = TCAPI_ERR_WHILE_CONFIGURING_MEDIA; |
139 |
} |
|
140 |
else |
|
141 |
{ |
|
142 |
if (ioctlsocket(m_socket, FIONBIO, &nonblock) == SOCKET_ERROR) |
|
143 |
{ |
|
144 |
m_lastCommError = WSAGetLastError(); |
|
366 | 145 |
WSASetLastError(0); |
60 | 146 |
closesocket(m_socket); |
147 |
m_socket = INVALID_SOCKET; |
|
366 | 148 |
WSAClose(); |
60 | 149 |
err = TCAPI_ERR_WHILE_CONFIGURING_MEDIA; |
150 |
} |
|
151 |
else |
|
152 |
{ |
|
153 |
int i = SO_MAX_MSG_SIZE; |
|
154 |
// set socket options |
|
389
de80f483b7e6
Turn keepalive back on to be compatible with 2.0.x releases.
Chad Peckham <chad.peckham@nokia.com>
parents:
366
diff
changeset
|
155 |
BOOL keepAlive = TRUE; |
60 | 156 |
setsockopt(m_socket, SOL_SOCKET, SO_KEEPALIVE, (const char*)&keepAlive, sizeof(BOOL)); |
366 | 157 |
|
158 |
struct linger l; |
|
159 |
l.l_onoff = 0; l.l_linger = 0; |
|
160 |
setsockopt(m_socket, SOL_SOCKET, SO_LINGER, (const char*)&l, sizeof(l)); |
|
161 |
||
60 | 162 |
int sockRecvSize = MAX_TCP_MESSAGE_BUFFER_LENGTH;//(256*1024L); |
163 |
setsockopt(m_socket, SOL_SOCKET, SO_RCVBUF, (const char*)&sockRecvSize, sizeof(int)); |
|
164 |
int sockSendSize = (64*1024L); |
|
165 |
setsockopt(m_socket, SOL_SOCKET, SO_SNDBUF, (const char*)&sockSendSize, sizeof(int)); |
|
166 |
WSAGetLastError(); // ignore error for now |
|
366 | 167 |
WSASetLastError(0); |
168 |
||
60 | 169 |
// connect |
170 |
WORD wPort = atoi(ipPort); |
|
171 |
m_clientService.sin_family = AF_INET; |
|
172 |
m_clientService.sin_addr.S_un.S_addr = inet_addr(ipAddress); |
|
173 |
m_clientService.sin_port = htons(wPort); |
|
478
2d6f57ea6ce2
Debug logging changes
Chad Peckham <chad.peckham@nokia.com>
parents:
458
diff
changeset
|
174 |
|
2d6f57ea6ce2
Debug logging changes
Chad Peckham <chad.peckham@nokia.com>
parents:
458
diff
changeset
|
175 |
COMMLOGS("CTcpComm::OpenPort connect start\n"); |
2d6f57ea6ce2
Debug logging changes
Chad Peckham <chad.peckham@nokia.com>
parents:
458
diff
changeset
|
176 |
|
60 | 177 |
if (connect(m_socket, (SOCKADDR*)&m_clientService, sizeof(m_clientService)) == SOCKET_ERROR) |
178 |
{ |
|
478
2d6f57ea6ce2
Debug logging changes
Chad Peckham <chad.peckham@nokia.com>
parents:
458
diff
changeset
|
179 |
COMMLOGS("CTcpComm::OpenPort connect SOCKET_ERROR\n"); |
60 | 180 |
int wsaErr = WSAGetLastError(); |
366 | 181 |
WSASetLastError(0); |
182 |
COMMLOGA1("CTcpComm::OpenPort connect=wsaErr=%d\n", wsaErr); |
|
183 |
||
60 | 184 |
// socket is non-blocking |
185 |
if (wsaErr != WSAEWOULDBLOCK) |
|
186 |
{ |
|
187 |
m_lastCommError = wsaErr; |
|
188 |
||
189 |
closesocket(m_socket); |
|
190 |
m_socket = INVALID_SOCKET; |
|
366 | 191 |
WSAClose(); |
60 | 192 |
err = TCAPI_ERR_WHILE_CONFIGURING_MEDIA; |
193 |
} |
|
194 |
else // WSAEWOULDBLOCK error returned |
|
195 |
{ |
|
196 |
// WSAEWOULDBLOCK use select now |
|
197 |
fd_set readfds, writefds, exceptfds; |
|
198 |
FD_ZERO(&readfds); |
|
199 |
FD_ZERO(&writefds); |
|
200 |
FD_ZERO(&exceptfds); |
|
201 |
FD_SET(m_socket, &readfds); |
|
202 |
FD_SET(m_socket, &writefds); |
|
203 |
FD_SET(m_socket, &exceptfds); |
|
204 |
||
205 |
int selRes = 0; |
|
206 |
while(1) |
|
207 |
{ |
|
208 |
selRes = select(0, &readfds, &writefds, &exceptfds, &m_timeOut); |
|
209 |
if (selRes == SOCKET_ERROR) |
|
210 |
{ |
|
211 |
wsaErr = WSAGetLastError(); |
|
366 | 212 |
WSASetLastError(0); |
60 | 213 |
if (wsaErr != WSAEWOULDBLOCK) |
214 |
{ |
|
215 |
// real error |
|
216 |
m_lastCommError = wsaErr; |
|
217 |
shutdown(m_socket, SD_BOTH); |
|
218 |
closesocket(m_socket); |
|
219 |
m_socket = INVALID_SOCKET; |
|
366 | 220 |
WSAClose(); |
60 | 221 |
err = TCAPI_ERR_WHILE_CONFIGURING_MEDIA; |
222 |
} |
|
223 |
// else do another select |
|
224 |
} |
|
225 |
else if (selRes > 0)// select OK |
|
226 |
{ |
|
227 |
m_lastCommError = 0; |
|
228 |
m_isConnected = true; |
|
229 |
break; // done |
|
230 |
} |
|
231 |
else |
|
232 |
{ |
|
233 |
// timed out |
|
234 |
m_lastCommError = WSAGetLastError(); |
|
366 | 235 |
WSASetLastError(0); |
60 | 236 |
shutdown(m_socket, SD_BOTH); |
237 |
closesocket(m_socket); |
|
238 |
m_socket = INVALID_SOCKET; |
|
366 | 239 |
WSAClose(); |
60 | 240 |
err = TCAPI_ERR_WHILE_CONFIGURING_MEDIA; |
241 |
} |
|
242 |
} |
|
243 |
} |
|
244 |
} |
|
245 |
else // connect return OK |
|
246 |
{ |
|
366 | 247 |
COMMLOGS("CTcpComm::OpenPort connect OK\n"); |
60 | 248 |
m_lastCommError = 0; |
249 |
m_isConnected = true; |
|
250 |
} |
|
251 |
} |
|
252 |
} |
|
253 |
} |
|
254 |
if (err == TCAPI_ERR_NONE) |
|
255 |
{ |
|
256 |
// we are connected |
|
257 |
m_numberBytes = 0; |
|
258 |
m_pBuffer = new BYTE[MAX_TCP_MESSAGE_BUFFER_LENGTH]; |
|
259 |
||
260 |
#ifdef USE_EVENTS |
|
261 |
// create an event for the socket closing |
|
262 |
m_hSocketEvent = WSACreateEvent(); |
|
263 |
::WSAEventSelect(m_socket, m_hSocketEvent, FD_CLOSE); |
|
264 |
// above call sets socket to non-blocking |
|
265 |
// cannot reset to blocking after using WSAEventSelect |
|
266 |
// thus this ioctlsocket call will fail |
|
267 |
ioctlsocket(m_socket, FIONBIO, &nonblock); |
|
268 |
#endif |
|
269 |
} |
|
270 |
||
366 | 271 |
COMMLOGA1("CTcpComm::OpenPort err=%d\n", err); |
60 | 272 |
COMMLOGCLOSE(); |
273 |
return err; |
|
274 |
} |
|
275 |
||
276 |
long CTcpComm::ClosePort() |
|
277 |
{ |
|
278 |
COMMLOGOPEN(); |
|
279 |
COMMLOGS("CTcpComm::ClosePort\n"); |
|
280 |
||
281 |
long err = TCAPI_ERR_NONE; |
|
282 |
||
283 |
if (!IsConnected()) |
|
284 |
{ |
|
285 |
err = TCAPI_ERR_MEDIA_NOT_OPEN; |
|
286 |
} |
|
287 |
else |
|
288 |
{ |
|
366 | 289 |
if (m_socket != INVALID_SOCKET) |
290 |
{ |
|
291 |
shutdown(m_socket, SD_BOTH); |
|
292 |
closesocket(m_socket); |
|
293 |
m_socket = INVALID_SOCKET; |
|
294 |
||
295 |
WSAClose(); |
|
296 |
} |
|
297 |
m_isConnected = false; |
|
60 | 298 |
|
299 |
delete[] m_pBuffer; |
|
300 |
m_pBuffer = NULL; |
|
301 |
||
302 |
if (m_hSocketEvent != WSA_INVALID_EVENT) |
|
303 |
{ |
|
304 |
WSACloseEvent(m_hSocketEvent); |
|
305 |
m_hSocketEvent = WSA_INVALID_EVENT; |
|
306 |
} |
|
307 |
} |
|
308 |
||
309 |
COMMLOGCLOSE(); |
|
310 |
return err; |
|
311 |
} |
|
312 |
||
313 |
long CTcpComm::PollPort(DWORD &outSize) |
|
314 |
{ |
|
315 |
long err = TCAPI_ERR_NONE; |
|
316 |
DWORD numBytes = 0; |
|
317 |
outSize = 0; |
|
318 |
||
319 |
if (!IsConnected()) |
|
320 |
return TCAPI_ERR_MEDIA_NOT_OPEN; |
|
321 |
||
322 |
#ifdef USE_EVENTS |
|
323 |
int ret = ::WSAWaitForMultipleEvents(1, &m_hSocketEvent, FALSE, 0, FALSE); |
|
324 |
if (ret == WSA_WAIT_EVENT_0) |
|
325 |
{ |
|
326 |
::WSAResetEvent(m_hSocketEvent); |
|
327 |
err = TCAPI_ERR_COMM_ERROR; |
|
328 |
m_lastCommError = WSAESHUTDOWN; |
|
329 |
return err; |
|
330 |
} |
|
331 |
#endif |
|
332 |
int sockErr = 0; int optLen = sizeof(int); |
|
333 |
int getErr = getsockopt(m_socket, SOL_SOCKET, SO_ERROR, (char*)&sockErr, &optLen); |
|
334 |
if (getErr == 0) |
|
335 |
{ |
|
336 |
if (sockErr) |
|
337 |
{ |
|
338 |
err = TCAPI_ERR_COMM_ERROR; |
|
339 |
m_lastCommError = sockErr; |
|
340 |
return err; |
|
341 |
} |
|
342 |
} |
|
343 |
||
344 |
fd_set readfds, writefds, exceptfds; |
|
345 |
FD_ZERO(&readfds); |
|
346 |
FD_ZERO(&writefds); |
|
347 |
FD_ZERO(&exceptfds); |
|
348 |
FD_SET(m_socket, &readfds); |
|
349 |
FD_SET(m_socket, &writefds); |
|
350 |
FD_SET(m_socket, &exceptfds); |
|
351 |
||
352 |
bool portReady = false; |
|
353 |
{ |
|
354 |
TIMEVAL pollTimeout = {0,0}; // just poll the status |
|
355 |
int selErr = select(0, &readfds, 0, 0, &pollTimeout); |
|
356 |
if (selErr > 0) |
|
357 |
{ |
|
358 |
if (FD_ISSET(m_socket, &readfds)) |
|
359 |
{ |
|
360 |
m_lastCommError = 0; |
|
361 |
portReady = true; |
|
362 |
} |
|
363 |
} |
|
364 |
else if (selErr == SOCKET_ERROR) |
|
365 |
{ |
|
366 |
m_lastCommError = WSAGetLastError(); |
|
366 | 367 |
WSASetLastError(0); |
60 | 368 |
err = TCAPI_ERR_COMM_ERROR; |
369 |
} |
|
370 |
} |
|
371 |
||
372 |
if (portReady) |
|
373 |
{ |
|
374 |
// read was signaled as ready |
|
375 |
int recvRet = recv(m_socket, (char*)&m_pPeekBuffer, sizeof(m_pPeekBuffer), MSG_PEEK); |
|
376 |
if (recvRet > 0) |
|
377 |
{ |
|
378 |
if (ioctlsocket(m_socket, FIONREAD, &numBytes) == 0) |
|
379 |
{ |
|
380 |
m_lastCommError = 0; |
|
381 |
outSize = numBytes; |
|
382 |
} |
|
383 |
else // SOCKET_ERROR |
|
384 |
{ |
|
385 |
m_lastCommError = WSAGetLastError(); |
|
366 | 386 |
WSASetLastError(0); |
60 | 387 |
err = TCAPI_ERR_COMM_ERROR; |
388 |
} |
|
389 |
} |
|
390 |
else if (recvRet == 0) |
|
391 |
{ |
|
392 |
// read was signalled as ready but recv=0 signals that remote shutdown |
|
393 |
m_lastCommError = WSAESHUTDOWN; |
|
394 |
err = TCAPI_ERR_COMM_ERROR; |
|
395 |
} |
|
396 |
else |
|
397 |
{ |
|
398 |
// SOCKET_ERROR: error on recv other than a shutdown |
|
399 |
m_lastCommError = WSAGetLastError(); |
|
366 | 400 |
WSASetLastError(0); |
60 | 401 |
err = TCAPI_ERR_COMM_ERROR; |
402 |
} |
|
403 |
} |
|
404 |
return err; |
|
405 |
} |
|
406 |
||
407 |
long CTcpComm::ReadPort(DWORD inSize, void *outData, DWORD &outSize) |
|
408 |
{ |
|
409 |
long err = TCAPI_ERR_NONE; |
|
410 |
DWORD numBytes = 0; |
|
411 |
outSize = 0; |
|
412 |
||
413 |
if (!IsConnected()) |
|
414 |
return TCAPI_ERR_MEDIA_NOT_OPEN; |
|
415 |
||
416 |
if (ioctlsocket(m_socket, FIONREAD, &numBytes) == 0) |
|
417 |
{ |
|
418 |
if (numBytes > inSize) |
|
419 |
numBytes = inSize; |
|
420 |
int res = recv(m_socket, (char*)outData, numBytes, 0); |
|
421 |
if (res == SOCKET_ERROR) |
|
422 |
{ |
|
423 |
long commErr = WSAGetLastError(); |
|
366 | 424 |
WSASetLastError(0); |
60 | 425 |
if ((DWORD)commErr != m_lastCommError) |
426 |
{ |
|
427 |
m_lastCommError = commErr; |
|
428 |
} |
|
429 |
err = TCAPI_ERR_COMM_ERROR; |
|
430 |
} |
|
431 |
else if (res == 0) |
|
432 |
{ |
|
433 |
// recv=0 --> connection closed |
|
434 |
m_lastCommError = WSAESHUTDOWN; |
|
435 |
err = TCAPI_ERR_COMM_ERROR; |
|
436 |
} |
|
437 |
else |
|
438 |
{ |
|
439 |
m_lastCommError = 0; |
|
440 |
outSize = numBytes; |
|
441 |
} |
|
442 |
} |
|
443 |
else |
|
444 |
{ |
|
445 |
// SOCKET_ERROR on ioctlsocket |
|
446 |
m_lastCommError = WSAGetLastError(); |
|
366 | 447 |
WSASetLastError(0); |
60 | 448 |
err = TCAPI_ERR_COMM_ERROR; |
449 |
} |
|
450 |
return err; |
|
451 |
} |
|
452 |
long CTcpComm::ProcessBuffer(CConnection* pConn, CRegistry* pRegistry, long& numberProcessed) |
|
453 |
{ |
|
454 |
||
455 |
long err = TCAPI_ERR_NONE; |
|
456 |
long routingErr = TCAPI_ERR_NONE; |
|
457 |
||
458 |
if (!IsConnected()) |
|
459 |
return TCAPI_ERR_MEDIA_NOT_OPEN; |
|
460 |
||
461 |
if (!m_Protocol) |
|
462 |
return TCAPI_ERR_UNKNOWN_MEDIA_TYPE; |
|
463 |
||
464 |
DWORD protocolHeaderLength = m_Protocol->GetHeaderLength(); |
|
465 |
||
466 |
// fill buffer |
|
467 |
if (m_numberBytes < MAX_TCP_MESSAGE_BUFFER_LENGTH) |
|
468 |
{ |
|
469 |
DWORD outLen = MAX_TCP_MESSAGE_BUFFER_LENGTH - m_numberBytes; |
|
470 |
BYTE* ptr = &m_pBuffer[m_numberBytes]; |
|
471 |
err = ReadPort(outLen, ptr, outLen); |
|
472 |
if (err == TCAPI_ERR_NONE && outLen > 0) |
|
473 |
{ |
|
474 |
m_numberBytes += outLen; |
|
475 |
} |
|
476 |
} |
|
477 |
||
478 |
// now process buffer but only for complete messages |
|
479 |
if (err == TCAPI_ERR_NONE) |
|
480 |
{ |
|
481 |
if (m_numberBytes >= protocolHeaderLength) |
|
482 |
{ |
|
483 |
BYTE* ptr = m_pBuffer; |
|
484 |
long bytesRemaining = m_numberBytes; |
|
485 |
long usedLen = 0; |
|
486 |
bool done = false; |
|
458 | 487 |
long numberSkipped=0; |
60 | 488 |
|
489 |
while (!done) |
|
490 |
{ |
|
491 |
DWORD fullMessageLength = bytesRemaining; |
|
492 |
DWORD rawLength = 0; |
|
493 |
BYTE* fullMessage = ptr; |
|
494 |
BYTE* rawMessage = ptr; |
|
495 |
BYTE msgId = 0; |
|
458 | 496 |
int result = m_Protocol->DecodeMessage(fullMessage, fullMessageLength, msgId, rawMessage, rawLength); |
497 |
if (result == DECODE_NOT_ENOUGH_BYTES_TO_SEARCH) |
|
498 |
{ |
|
499 |
done = true; |
|
500 |
} |
|
501 |
else if (result == DECODE_MESSAGE_NOT_FOUND) |
|
502 |
{ |
|
503 |
numberSkipped++; |
|
504 |
usedLen += fullMessageLength; |
|
505 |
bytesRemaining -= fullMessageLength; |
|
506 |
ptr += fullMessageLength; |
|
507 |
if (bytesRemaining < protocolHeaderLength) |
|
508 |
done = true; |
|
509 |
} |
|
510 |
else if (result == DECODE_MESSAGE_FOUND) |
|
60 | 511 |
{ |
512 |
err = PreProcessMessage(msgId, fullMessageLength, fullMessage); |
|
513 |
if (err != TCAPI_ERR_NONE) |
|
514 |
{ |
|
515 |
PROCLOGOPEN(); |
|
516 |
PROCLOGA1("CTcpComm::ProcessBuffer Notify err = %x\n", err); |
|
517 |
PROCLOGCLOSE(); |
|
518 |
// notify all clients right now |
|
519 |
pConn->NotifyClientsCommError(err, false, 0); |
|
520 |
err = TCAPI_ERR_NONE; |
|
521 |
} |
|
522 |
#ifdef _DEBUG |
|
523 |
int reallen = fullMessageLength; |
|
506
44dbbc3220b8
add different logging to send & recieve messages so we can see the messages better in debug version
Chad Peckham <chad.peckham@nokia.com>
parents:
478
diff
changeset
|
524 |
if (reallen > 100) reallen = 100; |
44dbbc3220b8
add different logging to send & recieve messages so we can see the messages better in debug version
Chad Peckham <chad.peckham@nokia.com>
parents:
478
diff
changeset
|
525 |
bool wasAlnum = false; |
60 | 526 |
char msg[6]; |
527 |
msg[0] = '\0'; |
|
528 |
||
529 |
sTcpLogMsg[0] = '\0'; |
|
530 |
if (reallen > 0) |
|
531 |
{ |
|
532 |
sTcpLogMsg[0] = '\0'; |
|
533 |
for (int i = 0; i < reallen; i++) |
|
534 |
{ |
|
506
44dbbc3220b8
add different logging to send & recieve messages so we can see the messages better in debug version
Chad Peckham <chad.peckham@nokia.com>
parents:
478
diff
changeset
|
535 |
if (isgraph/*isalnum*/(ptr[i]) && i > protocolHeaderLength) |
458 | 536 |
{ |
506
44dbbc3220b8
add different logging to send & recieve messages so we can see the messages better in debug version
Chad Peckham <chad.peckham@nokia.com>
parents:
478
diff
changeset
|
537 |
// string printables next to each other |
458 | 538 |
sprintf(msg, "%c", ptr[i]); |
506
44dbbc3220b8
add different logging to send & recieve messages so we can see the messages better in debug version
Chad Peckham <chad.peckham@nokia.com>
parents:
478
diff
changeset
|
539 |
wasAlnum = true; |
458 | 540 |
} |
541 |
else |
|
542 |
{ |
|
506
44dbbc3220b8
add different logging to send & recieve messages so we can see the messages better in debug version
Chad Peckham <chad.peckham@nokia.com>
parents:
478
diff
changeset
|
543 |
if (wasAlnum) |
44dbbc3220b8
add different logging to send & recieve messages so we can see the messages better in debug version
Chad Peckham <chad.peckham@nokia.com>
parents:
478
diff
changeset
|
544 |
{ |
44dbbc3220b8
add different logging to send & recieve messages so we can see the messages better in debug version
Chad Peckham <chad.peckham@nokia.com>
parents:
478
diff
changeset
|
545 |
// break from last alnum char |
44dbbc3220b8
add different logging to send & recieve messages so we can see the messages better in debug version
Chad Peckham <chad.peckham@nokia.com>
parents:
478
diff
changeset
|
546 |
sprintf(msg, " %02.2x ", ptr[i]); |
44dbbc3220b8
add different logging to send & recieve messages so we can see the messages better in debug version
Chad Peckham <chad.peckham@nokia.com>
parents:
478
diff
changeset
|
547 |
} |
44dbbc3220b8
add different logging to send & recieve messages so we can see the messages better in debug version
Chad Peckham <chad.peckham@nokia.com>
parents:
478
diff
changeset
|
548 |
else |
44dbbc3220b8
add different logging to send & recieve messages so we can see the messages better in debug version
Chad Peckham <chad.peckham@nokia.com>
parents:
478
diff
changeset
|
549 |
{ |
44dbbc3220b8
add different logging to send & recieve messages so we can see the messages better in debug version
Chad Peckham <chad.peckham@nokia.com>
parents:
478
diff
changeset
|
550 |
// no break |
44dbbc3220b8
add different logging to send & recieve messages so we can see the messages better in debug version
Chad Peckham <chad.peckham@nokia.com>
parents:
478
diff
changeset
|
551 |
sprintf(msg, "%02.2x ", ptr[i]); |
44dbbc3220b8
add different logging to send & recieve messages so we can see the messages better in debug version
Chad Peckham <chad.peckham@nokia.com>
parents:
478
diff
changeset
|
552 |
} |
44dbbc3220b8
add different logging to send & recieve messages so we can see the messages better in debug version
Chad Peckham <chad.peckham@nokia.com>
parents:
478
diff
changeset
|
553 |
wasAlnum = false; |
458 | 554 |
} |
60 | 555 |
strcat(sTcpLogMsg, msg); |
556 |
} |
|
557 |
} |
|
558 |
#endif |
|
559 |
PROCLOGOPEN(); |
|
458 | 560 |
PROCLOGA5("CTcpComm::ProcessBuffer - RouteMesssage pRegistry = %x id=%x len=%d len=%d msg=%s\n", pRegistry, msgId, fullMessageLength, rawLength, sTcpLogMsg); |
60 | 561 |
PROCLOGCLOSE(); |
562 |
||
563 |
err = pRegistry->RouteMessage(msgId, fullMessage, fullMessageLength, rawMessage, rawLength); |
|
564 |
if (err != TCAPI_ERR_NONE) routingErr = err; // saved for future |
|
565 |
||
566 |
numberProcessed++; |
|
567 |
usedLen += fullMessageLength; |
|
568 |
bytesRemaining -= fullMessageLength; |
|
569 |
ptr += fullMessageLength; |
|
570 |
if (bytesRemaining < protocolHeaderLength) |
|
571 |
done = true; |
|
572 |
} |
|
573 |
} |
|
574 |
DeleteMsg(usedLen); |
|
458 | 575 |
PROCLOGOPEN(); |
576 |
PROCLOGA2("CTcpComm::ProcessBuffer - numberSkipped=%d numberProcessed=%d\n", numberSkipped, numberProcessed); |
|
577 |
PROCLOGCLOSE(); |
|
60 | 578 |
} |
579 |
} |
|
580 |
||
581 |
if (routingErr == TCAPI_ERR_NONE) |
|
582 |
return err; |
|
583 |
else |
|
584 |
return routingErr; |
|
585 |
} |
|
586 |
||
587 |
||
588 |
long CTcpComm::SendDataToPort(DWORD inSize, const void* inData) |
|
589 |
{ |
|
590 |
COMMLOGOPEN(); |
|
591 |
COMMLOGS("CTcpComm::SendDataToPort\n"); |
|
592 |
||
593 |
long err = TCAPI_ERR_NONE; |
|
594 |
||
595 |
if (!IsConnected()) |
|
596 |
{ |
|
597 |
COMMLOGCLOSE(); |
|
598 |
return TCAPI_ERR_MEDIA_NOT_OPEN; |
|
599 |
} |
|
600 |
||
601 |
#ifdef USE_EVENTS |
|
602 |
int ret = ::WSAWaitForMultipleEvents(1, &m_hSocketEvent, FALSE, 0, FALSE); |
|
603 |
if (ret == WSA_WAIT_EVENT_0) |
|
604 |
{ |
|
605 |
::WSAResetEvent(m_hSocketEvent); |
|
606 |
err = TCAPI_ERR_COMM_ERROR; |
|
607 |
m_lastCommError = WSAESHUTDOWN; |
|
608 |
COMMLOGCLOSE(); |
|
609 |
return err; |
|
610 |
} |
|
611 |
#endif |
|
612 |
int sockErr = 0; int optLen = sizeof(int); |
|
613 |
int getErr = getsockopt(m_socket, SOL_SOCKET, SO_ERROR, (char*)&sockErr, &optLen); |
|
614 |
if (getErr == 0) |
|
615 |
{ |
|
616 |
if (sockErr) |
|
617 |
{ |
|
618 |
err = TCAPI_ERR_COMM_ERROR; |
|
619 |
m_lastCommError = sockErr; |
|
366 | 620 |
COMMLOGA1("CTcpComm::SendDataToPort getsockopt=%d\n", sockErr); |
60 | 621 |
COMMLOGCLOSE(); |
622 |
return err; |
|
623 |
} |
|
624 |
} |
|
625 |
||
626 |
fd_set readfds, writefds, exceptfds; |
|
627 |
FD_ZERO(&readfds); |
|
628 |
FD_ZERO(&writefds); |
|
629 |
FD_ZERO(&exceptfds); |
|
630 |
FD_SET(m_socket, &readfds); |
|
631 |
FD_SET(m_socket, &writefds); |
|
632 |
FD_SET(m_socket, &exceptfds); |
|
633 |
||
634 |
COMMLOGS("CTcpComm::SendDataToPort select\n"); |
|
635 |
bool portReady = false; |
|
636 |
{ |
|
637 |
int selErr = select(0, &readfds, &writefds, &exceptfds, &m_timeOut); |
|
638 |
if (selErr > 0) |
|
639 |
{ |
|
640 |
if (FD_ISSET(m_socket, &writefds)) |
|
641 |
{ |
|
642 |
m_lastCommError = 0; |
|
643 |
portReady = true; |
|
644 |
} |
|
645 |
} |
|
646 |
else if (selErr == SOCKET_ERROR) |
|
647 |
{ |
|
648 |
m_lastCommError = WSAGetLastError(); |
|
366 | 649 |
WSASetLastError(0); |
650 |
COMMLOGA1("CTcpComm::SendDataToPort select(SOCKET_ERROR)=%d\n", m_lastCommError); |
|
60 | 651 |
err = TCAPI_ERR_COMM_ERROR; |
652 |
} |
|
653 |
else if (selErr == 0) // timeout |
|
654 |
{ |
|
655 |
m_lastCommError = WSAGetLastError(); |
|
366 | 656 |
WSASetLastError(0); |
657 |
COMMLOGA1("CTcpComm::SendDataToPort select(timeout)=%d\n", m_lastCommError); |
|
60 | 658 |
err = TCAPI_ERR_COMM_ERROR; |
659 |
} |
|
660 |
} |
|
661 |
COMMLOGA1("CTcpComm::SendDataToPort portReady=%d\n", portReady); |
|
662 |
if (portReady) |
|
663 |
{ |
|
664 |
COMMLOGS("CTcpComm::SendDataToPort send start\n"); |
|
665 |
// loop until all bytes are sent |
|
666 |
DWORD bytesRemaining = inSize; |
|
667 |
DWORD nSent = 0; |
|
668 |
char* unsent = (char*)inData; |
|
669 |
while (bytesRemaining) |
|
670 |
{ |
|
671 |
nSent = send(m_socket, unsent, bytesRemaining, 0); |
|
672 |
if (nSent == SOCKET_ERROR) |
|
673 |
{ |
|
674 |
int wsaErr = WSAGetLastError(); |
|
366 | 675 |
WSASetLastError(0); |
60 | 676 |
// ignore "would block" errors |
677 |
if (wsaErr != WSAEWOULDBLOCK) |
|
678 |
{ |
|
679 |
// TODO: error handling |
|
366 | 680 |
COMMLOGA1("CTcpComm::SendDataToPort send(SOCKET_ERROR)=%d\n", wsaErr); |
60 | 681 |
m_lastCommError = wsaErr; |
682 |
err = TCAPI_ERR_COMM_ERROR; |
|
683 |
break; |
|
684 |
} |
|
685 |
} |
|
686 |
else |
|
687 |
{ |
|
688 |
m_lastCommError = 0; |
|
689 |
unsent += nSent; |
|
690 |
bytesRemaining -= nSent; |
|
691 |
} |
|
692 |
} // end while |
|
693 |
COMMLOGS("CTcpComm::SendDataToPort send done\n"); |
|
694 |
#ifdef _DEBUG |
|
506
44dbbc3220b8
add different logging to send & recieve messages so we can see the messages better in debug version
Chad Peckham <chad.peckham@nokia.com>
parents:
478
diff
changeset
|
695 |
DWORD protocolHeaderLength = m_Protocol->GetHeaderLength(); |
60 | 696 |
BYTE* ptr = (BYTE*)inData; |
506
44dbbc3220b8
add different logging to send & recieve messages so we can see the messages better in debug version
Chad Peckham <chad.peckham@nokia.com>
parents:
478
diff
changeset
|
697 |
int reallen = inSize; |
44dbbc3220b8
add different logging to send & recieve messages so we can see the messages better in debug version
Chad Peckham <chad.peckham@nokia.com>
parents:
478
diff
changeset
|
698 |
if (reallen > 100) reallen = 100; |
44dbbc3220b8
add different logging to send & recieve messages so we can see the messages better in debug version
Chad Peckham <chad.peckham@nokia.com>
parents:
478
diff
changeset
|
699 |
bool wasAlnum = false; |
44dbbc3220b8
add different logging to send & recieve messages so we can see the messages better in debug version
Chad Peckham <chad.peckham@nokia.com>
parents:
478
diff
changeset
|
700 |
char msg[6]; |
44dbbc3220b8
add different logging to send & recieve messages so we can see the messages better in debug version
Chad Peckham <chad.peckham@nokia.com>
parents:
478
diff
changeset
|
701 |
msg[0] = '\0'; |
44dbbc3220b8
add different logging to send & recieve messages so we can see the messages better in debug version
Chad Peckham <chad.peckham@nokia.com>
parents:
478
diff
changeset
|
702 |
|
44dbbc3220b8
add different logging to send & recieve messages so we can see the messages better in debug version
Chad Peckham <chad.peckham@nokia.com>
parents:
478
diff
changeset
|
703 |
sTcpLogMsgSend[0] = '\0'; |
44dbbc3220b8
add different logging to send & recieve messages so we can see the messages better in debug version
Chad Peckham <chad.peckham@nokia.com>
parents:
478
diff
changeset
|
704 |
if (reallen > 0) |
60 | 705 |
{ |
506
44dbbc3220b8
add different logging to send & recieve messages so we can see the messages better in debug version
Chad Peckham <chad.peckham@nokia.com>
parents:
478
diff
changeset
|
706 |
sTcpLogMsgSend[0] = '\0'; |
44dbbc3220b8
add different logging to send & recieve messages so we can see the messages better in debug version
Chad Peckham <chad.peckham@nokia.com>
parents:
478
diff
changeset
|
707 |
for (int i = 0; i < reallen; i++) |
44dbbc3220b8
add different logging to send & recieve messages so we can see the messages better in debug version
Chad Peckham <chad.peckham@nokia.com>
parents:
478
diff
changeset
|
708 |
{ |
44dbbc3220b8
add different logging to send & recieve messages so we can see the messages better in debug version
Chad Peckham <chad.peckham@nokia.com>
parents:
478
diff
changeset
|
709 |
if (isgraph/*isalnum*/(ptr[i]) && i > protocolHeaderLength) |
44dbbc3220b8
add different logging to send & recieve messages so we can see the messages better in debug version
Chad Peckham <chad.peckham@nokia.com>
parents:
478
diff
changeset
|
710 |
{ |
44dbbc3220b8
add different logging to send & recieve messages so we can see the messages better in debug version
Chad Peckham <chad.peckham@nokia.com>
parents:
478
diff
changeset
|
711 |
// string printables next to each other |
44dbbc3220b8
add different logging to send & recieve messages so we can see the messages better in debug version
Chad Peckham <chad.peckham@nokia.com>
parents:
478
diff
changeset
|
712 |
sprintf(msg, "%c", ptr[i]); |
44dbbc3220b8
add different logging to send & recieve messages so we can see the messages better in debug version
Chad Peckham <chad.peckham@nokia.com>
parents:
478
diff
changeset
|
713 |
wasAlnum = true; |
44dbbc3220b8
add different logging to send & recieve messages so we can see the messages better in debug version
Chad Peckham <chad.peckham@nokia.com>
parents:
478
diff
changeset
|
714 |
} |
44dbbc3220b8
add different logging to send & recieve messages so we can see the messages better in debug version
Chad Peckham <chad.peckham@nokia.com>
parents:
478
diff
changeset
|
715 |
else |
44dbbc3220b8
add different logging to send & recieve messages so we can see the messages better in debug version
Chad Peckham <chad.peckham@nokia.com>
parents:
478
diff
changeset
|
716 |
{ |
44dbbc3220b8
add different logging to send & recieve messages so we can see the messages better in debug version
Chad Peckham <chad.peckham@nokia.com>
parents:
478
diff
changeset
|
717 |
if (wasAlnum) |
44dbbc3220b8
add different logging to send & recieve messages so we can see the messages better in debug version
Chad Peckham <chad.peckham@nokia.com>
parents:
478
diff
changeset
|
718 |
{ |
44dbbc3220b8
add different logging to send & recieve messages so we can see the messages better in debug version
Chad Peckham <chad.peckham@nokia.com>
parents:
478
diff
changeset
|
719 |
// break from last alnum char |
44dbbc3220b8
add different logging to send & recieve messages so we can see the messages better in debug version
Chad Peckham <chad.peckham@nokia.com>
parents:
478
diff
changeset
|
720 |
sprintf(msg, " %02.2x ", ptr[i]); |
44dbbc3220b8
add different logging to send & recieve messages so we can see the messages better in debug version
Chad Peckham <chad.peckham@nokia.com>
parents:
478
diff
changeset
|
721 |
} |
44dbbc3220b8
add different logging to send & recieve messages so we can see the messages better in debug version
Chad Peckham <chad.peckham@nokia.com>
parents:
478
diff
changeset
|
722 |
else |
44dbbc3220b8
add different logging to send & recieve messages so we can see the messages better in debug version
Chad Peckham <chad.peckham@nokia.com>
parents:
478
diff
changeset
|
723 |
{ |
44dbbc3220b8
add different logging to send & recieve messages so we can see the messages better in debug version
Chad Peckham <chad.peckham@nokia.com>
parents:
478
diff
changeset
|
724 |
// no break |
44dbbc3220b8
add different logging to send & recieve messages so we can see the messages better in debug version
Chad Peckham <chad.peckham@nokia.com>
parents:
478
diff
changeset
|
725 |
sprintf(msg, "%02.2x ", ptr[i]); |
44dbbc3220b8
add different logging to send & recieve messages so we can see the messages better in debug version
Chad Peckham <chad.peckham@nokia.com>
parents:
478
diff
changeset
|
726 |
} |
44dbbc3220b8
add different logging to send & recieve messages so we can see the messages better in debug version
Chad Peckham <chad.peckham@nokia.com>
parents:
478
diff
changeset
|
727 |
wasAlnum = false; |
44dbbc3220b8
add different logging to send & recieve messages so we can see the messages better in debug version
Chad Peckham <chad.peckham@nokia.com>
parents:
478
diff
changeset
|
728 |
} |
44dbbc3220b8
add different logging to send & recieve messages so we can see the messages better in debug version
Chad Peckham <chad.peckham@nokia.com>
parents:
478
diff
changeset
|
729 |
strcat(sTcpLogMsgSend, msg); |
44dbbc3220b8
add different logging to send & recieve messages so we can see the messages better in debug version
Chad Peckham <chad.peckham@nokia.com>
parents:
478
diff
changeset
|
730 |
} |
60 | 731 |
} |
506
44dbbc3220b8
add different logging to send & recieve messages so we can see the messages better in debug version
Chad Peckham <chad.peckham@nokia.com>
parents:
478
diff
changeset
|
732 |
// BYTE* ptr = (BYTE*)inData; |
44dbbc3220b8
add different logging to send & recieve messages so we can see the messages better in debug version
Chad Peckham <chad.peckham@nokia.com>
parents:
478
diff
changeset
|
733 |
// long numBytes = (inSize > 20) ? 20 : inSize; |
44dbbc3220b8
add different logging to send & recieve messages so we can see the messages better in debug version
Chad Peckham <chad.peckham@nokia.com>
parents:
478
diff
changeset
|
734 |
// char msg[200]; |
44dbbc3220b8
add different logging to send & recieve messages so we can see the messages better in debug version
Chad Peckham <chad.peckham@nokia.com>
parents:
478
diff
changeset
|
735 |
// sprintf(msg, "CTcpComm::SendDataToPort data = "); |
44dbbc3220b8
add different logging to send & recieve messages so we can see the messages better in debug version
Chad Peckham <chad.peckham@nokia.com>
parents:
478
diff
changeset
|
736 |
// for (int i = 0; i < numBytes; i++) |
44dbbc3220b8
add different logging to send & recieve messages so we can see the messages better in debug version
Chad Peckham <chad.peckham@nokia.com>
parents:
478
diff
changeset
|
737 |
// { |
44dbbc3220b8
add different logging to send & recieve messages so we can see the messages better in debug version
Chad Peckham <chad.peckham@nokia.com>
parents:
478
diff
changeset
|
738 |
// sprintf(msg, "%s %02.2x", msg, ptr[i]); |
44dbbc3220b8
add different logging to send & recieve messages so we can see the messages better in debug version
Chad Peckham <chad.peckham@nokia.com>
parents:
478
diff
changeset
|
739 |
// } |
44dbbc3220b8
add different logging to send & recieve messages so we can see the messages better in debug version
Chad Peckham <chad.peckham@nokia.com>
parents:
478
diff
changeset
|
740 |
// sprintf(msg, "%s\n", msg); |
44dbbc3220b8
add different logging to send & recieve messages so we can see the messages better in debug version
Chad Peckham <chad.peckham@nokia.com>
parents:
478
diff
changeset
|
741 |
COMMLOGA2("CTcpComm::SendDataToPort len=%d msg=%s\n", inSize, sTcpLogMsgSend); |
60 | 742 |
#endif |
743 |
} |
|
744 |
||
745 |
COMMLOGCLOSE(); |
|
746 |
return err; |
|
747 |
} |
|
748 |
||
749 |
void CTcpComm::DeleteMsg(DWORD inMsgLength) |
|
750 |
{ |
|
751 |
// inMsgLength includes header |
|
752 |
// delete from beginning of buffer |
|
753 |
if (inMsgLength == 0) |
|
754 |
return; |
|
755 |
if (m_numberBytes > 0 && m_numberBytes >= inMsgLength) |
|
756 |
{ |
|
757 |
size_t moveLen = m_numberBytes - inMsgLength; |
|
758 |
if (moveLen > 0) |
|
759 |
memcpy(&m_pBuffer[0], &m_pBuffer[inMsgLength], moveLen); |
|
760 |
m_numberBytes -= inMsgLength; |
|
761 |
} |
|
762 |
} |
|
763 |
bool CTcpComm::IsConnectionEqual(ConnectData* pConn) |
|
764 |
{ |
|
366 | 765 |
if ((strcmp(pConn->tcpSettings.ipAddress, m_ConnectSettings->tcpSettings.ipAddress) == 0)) |
60 | 766 |
{ |
366 | 767 |
if ((strcmp(pConn->tcpSettings.ipPort, m_ConnectSettings->tcpSettings.ipPort) == 0)) |
768 |
{ |
|
769 |
// same port and same IP |
|
770 |
return true; |
|
771 |
} |
|
772 |
else |
|
773 |
{ |
|
774 |
// different port but same IP |
|
775 |
return false; |
|
776 |
} |
|
60 | 777 |
} |
778 |
else |
|
779 |
{ |
|
366 | 780 |
// different IP |
60 | 781 |
return false; |
782 |
} |
|
783 |
} |
|
784 |
||
366 | 785 |
int CTcpComm::WSAInit() |
786 |
{ |
|
787 |
int wsaErr = 0; |
|
788 |
||
789 |
COMMLOGOPEN(); |
|
790 |
COMMLOGS("CTcpComm::WSAInit\n"); |
|
791 |
||
792 |
WSADATA wsaData; |
|
793 |
wsaErr = WSAStartup(MAKEWORD(2,2), &wsaData); |
|
794 |
||
795 |
COMMLOGCLOSE(); |
|
796 |
return wsaErr; |
|
797 |
} |
|
798 |
||
799 |
void CTcpComm::WSAClose() |
|
800 |
{ |
|
801 |
COMMLOGOPEN(); |
|
802 |
COMMLOGS("CTcpComm::WSAClose\n"); |
|
803 |
||
804 |
WSACleanup(); |
|
805 |
||
806 |
COMMLOGCLOSE(); |
|
807 |
} |
|
808 |