313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
|
int operation, /* Whether to add or remove from the mask. */
TcpState *payload) /* What socket to add/remove. */
{
SendMessageW(tsdPtr->hwnd, SOCKET_SELECT, (WPARAM) operation,
(LPARAM) payload);
}
/*
* Address print debug functions
*/
#if 0
static inline void
printaddrinfo(
struct addrinfo *ai,
char *prefix)
{
char host[NI_MAXHOST], port[NI_MAXSERV];
getnameinfo(ai->ai_addr, ai->ai_addrlen,
host, sizeof(host), port, sizeof(port),
NI_NUMERICHOST | NI_NUMERICSERV);
}
static void
printaddrinfolist(
struct addrinfo *addrlist,
char *prefix)
{
struct addrinfo *ai;
for (ai = addrlist; ai != NULL; ai = ai->ai_next) {
printaddrinfo(ai, prefix);
}
}
#endif
/*
*----------------------------------------------------------------------
*
* InitializeHostName --
*
* This routine sets the process global value of the name of the local
* host on which the process is running.
|
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
|
313
314
315
316
317
318
319
320
321
322
323
324
325
326
|
int operation, /* Whether to add or remove from the mask. */
TcpState *payload) /* What socket to add/remove. */
{
SendMessageW(tsdPtr->hwnd, SOCKET_SELECT, (WPARAM) operation,
(LPARAM) payload);
}
/*
*----------------------------------------------------------------------
*
* InitializeHostName --
*
* This routine sets the process global value of the name of the local
* host on which the process is running.
|
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
|
PostMessageW(tsdPtr->hwnd, SOCKET_TERMINATE, 0, 0);
/*
* Wait for the thread to exit. This ensures that we are
* completely cleaned up before we leave this function.
*/
WaitForSingleObject(tsdPtr->readyEvent, INFINITE);
tsdPtr->hwnd = NULL;
}
CloseHandle(tsdPtr->socketThread);
tsdPtr->socketThread = NULL;
}
if (tsdPtr->readyEvent != NULL) {
CloseHandle(tsdPtr->readyEvent);
|
|
|
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
|
PostMessageW(tsdPtr->hwnd, SOCKET_TERMINATE, 0, 0);
/*
* Wait for the thread to exit. This ensures that we are
* completely cleaned up before we leave this function.
*/
WaitForSingleObject(tsdPtr->socketThread, INFINITE);
tsdPtr->hwnd = NULL;
}
CloseHandle(tsdPtr->socketThread);
tsdPtr->socketThread = NULL;
}
if (tsdPtr->readyEvent != NULL) {
CloseHandle(tsdPtr->readyEvent);
|
2217
2218
2219
2220
2221
2222
2223
2224
2225
2226
2227
2228
2229
2230
|
* place to look for bugs.
*/
if (bind(sock, addrPtr->ai_addr,
(socklen_t)addrPtr->ai_addrlen) == SOCKET_ERROR) {
Tcl_WinConvertError((DWORD) WSAGetLastError());
closesocket(sock);
continue;
}
if (port == 0 && chosenport == 0) {
address sockname;
socklen_t namelen = sizeof(sockname);
/*
|
>
|
2188
2189
2190
2191
2192
2193
2194
2195
2196
2197
2198
2199
2200
2201
2202
|
* place to look for bugs.
*/
if (bind(sock, addrPtr->ai_addr,
(socklen_t)addrPtr->ai_addrlen) == SOCKET_ERROR) {
Tcl_WinConvertError((DWORD) WSAGetLastError());
closesocket(sock);
sock = INVALID_SOCKET; /* Bug [40b1814b93] */
continue;
}
if (port == 0 && chosenport == 0) {
address sockname;
socklen_t namelen = sizeof(sockname);
/*
|
2245
2246
2247
2248
2249
2250
2251
2252
2253
2254
2255
2256
2257
2258
|
if (backlog < 0) {
backlog = SOMAXCONN;
}
if (listen(sock, backlog) == SOCKET_ERROR) {
Tcl_WinConvertError((DWORD) WSAGetLastError());
closesocket(sock);
continue;
}
if (statePtr == NULL) {
/*
* Add this socket to the global list of sockets.
*/
|
>
|
2217
2218
2219
2220
2221
2222
2223
2224
2225
2226
2227
2228
2229
2230
2231
|
if (backlog < 0) {
backlog = SOMAXCONN;
}
if (listen(sock, backlog) == SOCKET_ERROR) {
Tcl_WinConvertError((DWORD) WSAGetLastError());
closesocket(sock);
sock = INVALID_SOCKET; /* Bug [40b1814b93] */
continue;
}
if (statePtr == NULL) {
/*
* Add this socket to the global list of sockets.
*/
|