Lines Matching refs:sock

142 mDNSlocal void				TCPCanRead( TCPSocket * sock );
143 mDNSlocal mStatus TCPBeginRecv( TCPSocket * sock );
146 mDNSlocal void CALLBACK TCPFreeSocket( TCPSocket *sock );
149 mDNSlocal void UDPCloseSocket( UDPSocket * sock );
150 mDNSlocal void CALLBACK UDPFreeSocket( UDPSocket * sock );
164 mDNSlocal void DispatchUDPEvent( mDNS * const m, UDPSocket * sock );
165 mDNSlocal void DispatchTCPEvent( mDNS * const m, TCPSocket * sock );
965 TCPSocket * sock = NULL; in mDNSPlatformTCPSocket() local
977 sock = (TCPSocket *) malloc( sizeof( TCPSocket ) ); in mDNSPlatformTCPSocket()
978 require_action( sock, exit, err = mStatus_NoMemoryErr ); in mDNSPlatformTCPSocket()
979 mDNSPlatformMemZero( sock, sizeof( TCPSocket ) ); in mDNSPlatformTCPSocket()
980 sock->fd = INVALID_SOCKET; in mDNSPlatformTCPSocket()
981 sock->flags = flags; in mDNSPlatformTCPSocket()
982 sock->m = m; in mDNSPlatformTCPSocket()
991 sock->fd = socket(AF_INET, SOCK_STREAM, 0); in mDNSPlatformTCPSocket()
992 err = translate_errno( sock->fd != INVALID_SOCKET, WSAGetLastError(), mStatus_UnknownErr ); in mDNSPlatformTCPSocket()
997 err = bind( sock->fd, ( struct sockaddr* ) &saddr, sizeof( saddr ) ); in mDNSPlatformTCPSocket()
1003 err = ioctlsocket( sock->fd, FIONBIO, &on ); in mDNSPlatformTCPSocket()
1012 err = getsockname( sock->fd, ( struct sockaddr* ) &saddr, &len ); in mDNSPlatformTCPSocket()
1020 if ( err && sock ) in mDNSPlatformTCPSocket()
1022 TCPFreeSocket( sock ); in mDNSPlatformTCPSocket()
1023 sock = mDNSNULL; in mDNSPlatformTCPSocket()
1026 return sock; in mDNSPlatformTCPSocket()
1036 TCPSocket * sock, in mDNSPlatformTCPConnect() argument
1059 sock->readEventHandler = TCPCanRead; in mDNSPlatformTCPConnect()
1060 sock->userCallback = inCallback; in mDNSPlatformTCPConnect()
1061 sock->userContext = inContext; in mDNSPlatformTCPConnect()
1070 err = connect( sock->fd, ( struct sockaddr* ) &saddr, sizeof( saddr ) ); in mDNSPlatformTCPConnect()
1072 sock->connected = !err ? TRUE : FALSE; in mDNSPlatformTCPConnect()
1074 if ( sock->connected ) in mDNSPlatformTCPConnect()
1076 err = TCPAddSocket( sock->m, sock ); in mDNSPlatformTCPConnect()
1081 require_action( sock->m->p->registerWaitableEventFunc != NULL, exit, err = mStatus_ConnFailed ); in mDNSPlatformTCPConnect()
1083 sock->connectEvent = CreateEvent( NULL, FALSE, FALSE, NULL ); in mDNSPlatformTCPConnect()
1084 err = translate_errno( sock->connectEvent, GetLastError(), mStatus_UnknownErr ); in mDNSPlatformTCPConnect()
1087 err = WSAEventSelect( sock->fd, sock->connectEvent, FD_CONNECT ); in mDNSPlatformTCPConnect()
1090 err = sock->m->p->registerWaitableEventFunc( sock->m, sock->connectEvent, sock, TCPDidConnect ); in mDNSPlatformTCPConnect()
1098 err = sock->connected ? mStatus_ConnEstablished : mStatus_ConnPending; in mDNSPlatformTCPConnect()
1111 TCPSocket * sock = NULL; in mDNSPlatformTCPAccept() local
1116 sock = malloc( sizeof( TCPSocket ) ); in mDNSPlatformTCPAccept()
1117 require_action( sock, exit, err = mStatus_NoMemoryErr ); in mDNSPlatformTCPAccept()
1119 mDNSPlatformMemZero( sock, sizeof( *sock ) ); in mDNSPlatformTCPAccept()
1121 sock->fd = fd; in mDNSPlatformTCPAccept()
1122 sock->flags = flags; in mDNSPlatformTCPAccept()
1126 if ( err && sock ) in mDNSPlatformTCPAccept()
1128 free( sock ); in mDNSPlatformTCPAccept()
1129 sock = NULL; in mDNSPlatformTCPAccept()
1132 return sock; in mDNSPlatformTCPAccept()
1140 mDNSexport void mDNSPlatformTCPCloseConnection( TCPSocket *sock ) in mDNSPlatformTCPCloseConnection() argument
1142 check( sock ); in mDNSPlatformTCPCloseConnection()
1144 if ( sock->connectEvent && sock->m->p->unregisterWaitableEventFunc ) in mDNSPlatformTCPCloseConnection()
1146 sock->m->p->unregisterWaitableEventFunc( sock->m, sock->connectEvent ); in mDNSPlatformTCPCloseConnection()
1149 if ( sock->fd != INVALID_SOCKET ) in mDNSPlatformTCPCloseConnection()
1151 TCPCloseSocket( sock ); in mDNSPlatformTCPCloseConnection()
1153 QueueUserAPC( ( PAPCFUNC ) TCPFreeSocket, sock->m->p->mainThread, ( ULONG_PTR ) sock ); in mDNSPlatformTCPCloseConnection()
1162 mDNSexport long mDNSPlatformReadTCP( TCPSocket *sock, void *inBuffer, unsigned long inBufferSize, m… in mDNSPlatformReadTCP() argument
1168 *closed = sock->closed; in mDNSPlatformReadTCP()
1169 wsaError = sock->lastError; in mDNSPlatformReadTCP()
1176 else if ( sock->lastError == 0 ) in mDNSPlatformReadTCP()
1180 bytesLeft = ( DWORD ) ( sock->eptr - sock->bptr ); in mDNSPlatformReadTCP()
1186 memcpy( inBuffer, sock->bptr, bytesToCopy ); in mDNSPlatformReadTCP()
1187 sock->bptr += bytesToCopy; in mDNSPlatformReadTCP()
1189 if ( !sock->overlapped.pending && ( sock->bptr == sock->eptr ) ) in mDNSPlatformReadTCP()
1191 sock->bptr = sock->bbuf; in mDNSPlatformReadTCP()
1192 sock->eptr = sock->bbuf; in mDNSPlatformReadTCP()
1215 mDNSexport long mDNSPlatformWriteTCP( TCPSocket *sock, const char *inMsg, unsigned long inMsgSize ) in mDNSPlatformWriteTCP() argument
1220 nsent = send( sock->fd, inMsg, inMsgSize, 0 ); in mDNSPlatformWriteTCP()
1239 mDNSexport int mDNSPlatformTCPGetFD(TCPSocket *sock ) in mDNSPlatformTCPGetFD() argument
1241 return ( int ) sock->fd; in mDNSPlatformTCPGetFD()
1249 mStatus TCPAddSocket( mDNS * const inMDNS, TCPSocket *sock ) in TCPAddSocket() argument
1255 sock->bptr = sock->bbuf; in TCPAddSocket()
1256 sock->eptr = sock->bbuf; in TCPAddSocket()
1257 sock->ebuf = sock->bbuf + sizeof( sock->bbuf ); in TCPAddSocket()
1259 dlog( kDebugLevelChatty, DEBUG_NAME "adding TCPSocket 0x%x:%d\n", sock, sock->fd ); in TCPAddSocket()
1260 err = TCPBeginRecv( sock ); in TCPAddSocket()
1275 TCPSocket * sock = ( TCPSocket* ) context; in TCPDidConnect() local
1285 if ( sock ) in TCPDidConnect()
1287 callback = ( TCPConnectionCallback ) sock->userCallback; in TCPDidConnect()
1288 err = WSAEnumNetworkEvents( sock->fd, sock->connectEvent, &sockEvent ); in TCPDidConnect()
1293 sock->connected = mDNStrue; in TCPDidConnect()
1295 if ( sock->fd != INVALID_SOCKET ) in TCPDidConnect()
1297 err = TCPAddSocket( sock->m, sock ); in TCPDidConnect()
1303 callback( sock, sock->userContext, TRUE, 0 ); in TCPDidConnect()
1311 callback( sock, sock->userContext, TRUE, err ); in TCPDidConnect()
1321 mDNSlocal void TCPCanRead( TCPSocket * sock ) in TCPCanRead() argument
1323 TCPConnectionCallback callback = ( TCPConnectionCallback ) sock->userCallback; in TCPCanRead()
1327 callback( sock, sock->userContext, mDNSfalse, sock->lastError ); in TCPCanRead()
1336 mDNSlocal mStatus TCPBeginRecv( TCPSocket * sock ) in TCPBeginRecv() argument
1342 dlog( kDebugLevelChatty, DEBUG_NAME "%s: sock = %d\n", __ROUTINE__, sock->fd ); in TCPBeginRecv()
1344 check( !sock->overlapped.pending ); in TCPBeginRecv()
1346 ZeroMemory( &sock->overlapped.data, sizeof( sock->overlapped.data ) ); in TCPBeginRecv()
1347 sock->overlapped.data.hEvent = sock; in TCPBeginRecv()
1349 sock->overlapped.wbuf.buf = ( char* ) sock->eptr; in TCPBeginRecv()
1350 sock->overlapped.wbuf.len = ( ULONG) ( sock->ebuf - sock->eptr ); in TCPBeginRecv()
1352 …err = WSARecv( sock->fd, &sock->overlapped.wbuf, 1, &bytesReceived, &flags, &sock->overlapped.data… in TCPBeginRecv()
1356 sock->overlapped.pending = TRUE; in TCPBeginRecv()
1370 TCPSocket * sock; in TCPEndRecv() local
1375 sock = ( overlapped != NULL ) ? overlapped->hEvent : NULL; in TCPEndRecv()
1376 require_action( sock, exit, error = ( DWORD ) mStatus_BadStateErr ); in TCPEndRecv()
1377 dlog( kDebugLevelChatty, DEBUG_NAME "%s: sock = %d\n", __ROUTINE__, sock->fd ); in TCPEndRecv()
1378 sock->overlapped.error = error; in TCPEndRecv()
1379 sock->overlapped.bytesTransferred = bytesTransferred; in TCPEndRecv()
1380 check( sock->overlapped.pending ); in TCPEndRecv()
1381 sock->overlapped.pending = FALSE; in TCPEndRecv()
1385 AddToTail( &gTCPDispatchableSockets, sock ); in TCPEndRecv()
1400 UDPSocket* sock = NULL; in mDNSPlatformUDPSocket() local
1407 sock = ( UDPSocket* ) malloc(sizeof( UDPSocket ) ); in mDNSPlatformUDPSocket()
1408 require_action( sock, exit, err = mStatus_NoMemoryErr ); in mDNSPlatformUDPSocket()
1409 memset( sock, 0, sizeof( UDPSocket ) ); in mDNSPlatformUDPSocket()
1413 sock->fd = INVALID_SOCKET; in mDNSPlatformUDPSocket()
1414 sock->recvMsgPtr = m->p->unicastSock4.recvMsgPtr; in mDNSPlatformUDPSocket()
1415 sock->addr = m->p->unicastSock4.addr; in mDNSPlatformUDPSocket()
1416 sock->ifd = NULL; in mDNSPlatformUDPSocket()
1417 sock->overlapped.pending = FALSE; in mDNSPlatformUDPSocket()
1418 sock->m = m; in mDNSPlatformUDPSocket()
1439 err = SetupSocket(m, ( struct sockaddr* ) &saddr, port, &sock->fd ); in mDNSPlatformUDPSocket()
1447 sock->port = port; in mDNSPlatformUDPSocket()
1451 err = UDPBeginRecv( sock ); in mDNSPlatformUDPSocket()
1456 sock->next = gUDPSockets; in mDNSPlatformUDPSocket()
1457 gUDPSockets = sock; in mDNSPlatformUDPSocket()
1462 if ( err && sock ) in mDNSPlatformUDPSocket()
1464 UDPFreeSocket( sock ); in mDNSPlatformUDPSocket()
1465 sock = NULL; in mDNSPlatformUDPSocket()
1468 return sock; in mDNSPlatformUDPSocket()
1475 mDNSexport void mDNSPlatformUDPClose( UDPSocket *sock ) in mDNSPlatformUDPClose() argument
1482 if ( current == sock ) in mDNSPlatformUDPClose()
1486 gUDPSockets = sock->next; in mDNSPlatformUDPClose()
1490 last->next = sock->next; in mDNSPlatformUDPClose()
1504 UDPCloseSocket( sock ); in mDNSPlatformUDPClose()
1506 QueueUserAPC( ( PAPCFUNC ) UDPFreeSocket, sock->m->p->mainThread, ( ULONG_PTR ) sock ); in mDNSPlatformUDPClose()
1557 sendingsocket = ifd ? ifd->sock.fd : inMDNS->p->unicastSock4.fd; in mDNSPlatformSendUDP()
1571 sendingsocket = ifd ? ifd->sock.fd : inMDNS->p->unicastSock6.fd; in mDNSPlatformSendUDP()
2623 inMDNS->p->unicastSock4.addr = ifd->sock.addr; in SetupInterfaceList()
2651 inMDNS->p->unicastSock6.addr = ifd->sock.addr; in SetupInterfaceList()
2746 ifd->sock.fd = kInvalidSocketRef; in SetupInterface()
2747 ifd->sock.overlapped.pending = FALSE; in SetupInterface()
2748 ifd->sock.ifd = ifd; in SetupInterface()
2749 ifd->sock.next = NULL; in SetupInterface()
2750 ifd->sock.m = inMDNS; in SetupInterface()
2801 err = SetupSocket( inMDNS, inIFA->ifa_addr, MulticastDNSPort, &ifd->sock.fd ); in SetupInterface()
2803 …ifd->sock.addr = ( inIFA->ifa_addr->sa_family == AF_INET6 ) ? AllDNSLinkGroup_v6 : AllDNSLinkGroup… in SetupInterface()
2804 ifd->sock.port = MulticastDNSPort; in SetupInterface()
2808 …octl( ifd->sock.fd, SIO_GET_EXTENSION_FUNCTION_POINTER, &kWSARecvMsgGUID, sizeof( kWSARecvMsgGUID … in SetupInterface()
2812 ifd->sock.recvMsgPtr = NULL; in SetupInterface()
2835 if ( ifd->sock.fd != kInvalidSocketRef ) in SetupInterface()
2837 err = UDPBeginRecv( &ifd->sock ); in SetupInterface()
2883 UDPCloseSocket( &inIFD->sock ); in TearDownInterface()
2915 SocketRef sock; in SetupSocket() local
2928 sock = socket( inAddr->sa_family, SOCK_DGRAM, IPPROTO_UDP ); in SetupSocket()
2929 err = translate_errno( IsValidSocket( sock ), errno_compat(), kUnknownErr ); in SetupSocket()
2938 err = setsockopt( sock, SOL_SOCKET, SO_REUSEADDR, (char *) &option, sizeof( option ) ); in SetupSocket()
2960 …err = WSAIoctl( sock, SIO_UDP_CONNRESET, &behavior, sizeof(behavior), NULL, 0, &bytesReturned, NUL… in SetupSocket()
2977 err = bind( sock, (struct sockaddr *) &sa4, sizeof( sa4 ) ); in SetupSocket()
2983 err = setsockopt( sock, IPPROTO_IP, IP_PKTINFO, (char *) &option, sizeof( option ) ); in SetupSocket()
2992 err = setsockopt( sock, IPPROTO_IP, IP_ADD_MEMBERSHIP, (char *) &mreqv4, sizeof( mreqv4 ) ); in SetupSocket()
2998 …err = setsockopt( sock, IPPROTO_IP, IP_MULTICAST_IF, (char *) &sa4.sin_addr, sizeof( sa4.sin_addr … in SetupSocket()
3004 err = setsockopt( sock, IPPROTO_IP, IP_MULTICAST_LOOP, (char *) &option, sizeof( option ) ); in SetupSocket()
3011 err = setsockopt( sock, IPPROTO_IP, IP_TTL, (char *) &option, sizeof( option ) ); in SetupSocket()
3017 err = setsockopt( sock, IPPROTO_IP, IP_MULTICAST_TTL, (char *) &option, sizeof( option ) ); in SetupSocket()
3038 err = bind( sock, (struct sockaddr *) &sa6, sizeof( sa6 ) ); in SetupSocket()
3044 err = setsockopt( sock, IPPROTO_IPV6, IPV6_PKTINFO, (char *) &option, sizeof( option ) ); in SetupSocket()
3053 err = setsockopt( sock, IPPROTO_IPV6, IPV6_V6ONLY, (char *) &option, sizeof( option ) ); in SetupSocket()
3063 err = setsockopt( sock, IPPROTO_IPV6, IPV6_JOIN_GROUP, (char *) &mreqv6, sizeof( mreqv6 ) ); in SetupSocket()
3069 err = setsockopt( sock, IPPROTO_IPV6, IPV6_MULTICAST_IF, (char *) &option, sizeof( option ) ); in SetupSocket()
3075 err = setsockopt( sock, IPPROTO_IPV6, IPV6_MULTICAST_LOOP, (char *) &option, sizeof( option ) ); in SetupSocket()
3082 err = setsockopt( sock, IPPROTO_IPV6, IPV6_UNICAST_HOPS, (char *) &option, sizeof( option ) ); in SetupSocket()
3088 err = setsockopt( sock, IPPROTO_IPV6, IPV6_MULTICAST_HOPS, (char *) &option, sizeof( option ) ); in SetupSocket()
3100 *outSocketRef = sock; in SetupSocket()
3101 sock = kInvalidSocketRef; in SetupSocket()
3105 if( IsValidSocket( sock ) ) in SetupSocket()
3107 close_compat( sock ); in SetupSocket()
3170 mDNSlocal OSStatus UDPBeginRecv( UDPSocket * sock ) in UDPBeginRecv() argument
3176 dlog( kDebugLevelChatty, DEBUG_NAME "%s: sock = %d\n", __ROUTINE__, sock->fd ); in UDPBeginRecv()
3178 require_action( sock != NULL, exit, err = mStatus_BadStateErr ); in UDPBeginRecv()
3179 check( !sock->overlapped.pending ); in UDPBeginRecv()
3183 sock->overlapped.wbuf.buf = (char *) &sock->packet; in UDPBeginRecv()
3184 sock->overlapped.wbuf.len = (u_long) sizeof( sock->packet ); in UDPBeginRecv()
3185 sock->srcAddrLen = sizeof( sock->srcAddr ); in UDPBeginRecv()
3189 ZeroMemory( &sock->overlapped.data, sizeof( OVERLAPPED ) ); in UDPBeginRecv()
3190 sock->overlapped.data.hEvent = sock; in UDPBeginRecv()
3196 if ( sock->recvMsgPtr ) in UDPBeginRecv()
3198 sock->wmsg.name = ( LPSOCKADDR ) &sock->srcAddr; in UDPBeginRecv()
3199 sock->wmsg.namelen = sock->srcAddrLen; in UDPBeginRecv()
3200 sock->wmsg.lpBuffers = &sock->overlapped.wbuf; in UDPBeginRecv()
3201 sock->wmsg.dwBufferCount = 1; in UDPBeginRecv()
3202 sock->wmsg.Control.buf = ( CHAR* ) sock->controlBuffer; in UDPBeginRecv()
3203 sock->wmsg.Control.len = sizeof( sock->controlBuffer ); in UDPBeginRecv()
3204 sock->wmsg.dwFlags = 0; in UDPBeginRecv()
3206 …err = sock->recvMsgPtr( sock->fd, &sock->wmsg, &size, &sock->overlapped.data, ( LPWSAOVERLAPPED_CO… in UDPBeginRecv()
3216 if ( err == WSAEFAULT ) sock->recvMsgPtr = NULL; in UDPBeginRecv()
3222 …err = WSARecvFrom( sock->fd, &sock->overlapped.wbuf, 1, NULL, &flags, ( LPSOCKADDR ) &sock->srcAdd… in UDPBeginRecv()
3239 sock->overlapped.pending = TRUE; in UDPBeginRecv()
3258 UDPSocket * sock = NULL; in UDPEndRecv() local
3265 sock = ( overlapped != NULL ) ? overlapped->hEvent : NULL; in UDPEndRecv()
3266 require_action( sock != NULL, exit, err = ( DWORD ) kUnknownErr ); in UDPEndRecv()
3267 dlog( kDebugLevelChatty, DEBUG_NAME "%s: sock = %d\n", __ROUTINE__, sock->fd ); in UDPEndRecv()
3268 sock->overlapped.error = err; in UDPEndRecv()
3269 sock->overlapped.bytesTransferred = bytesTransferred; in UDPEndRecv()
3270 check( sock->overlapped.pending ); in UDPEndRecv()
3271 sock->overlapped.pending = FALSE; in UDPEndRecv()
3275 …SockAddrToMDNSAddr( (struct sockaddr *) &sock->srcAddr, &sock->overlapped.srcAddr, &sock->overlapp… in UDPEndRecv()
3281 sock->overlapped.dstAddr = sock->addr; in UDPEndRecv()
3282 sock->overlapped.dstPort = sock->port; in UDPEndRecv()
3284 if ( sock->recvMsgPtr ) in UDPEndRecv()
3303 …for ( header = WSA_CMSG_FIRSTHDR( &sock->wmsg ); header; header = WSA_CMSG_NXTHDR( &sock->wmsg, he… in UDPEndRecv()
3315 if ( sock->ifd != NULL ) in UDPEndRecv()
3317 …require_action( ipv4PacketInfo->ipi_ifindex == sock->ifd->index, exit, err = ( DWORD ) kMismatchEr… in UDPEndRecv()
3320 sock->overlapped.dstAddr.type = mDNSAddrType_IPv4; in UDPEndRecv()
3321 sock->overlapped.dstAddr.ip.v4.NotAnInteger = ipv4PacketInfo->ipi_addr.s_addr; in UDPEndRecv()
3329 if ( sock->ifd != NULL ) in UDPEndRecv()
3331 …require_action( ipv6PacketInfo->ipi6_ifindex == ( sock->ifd->index - kIPv6IfIndexBase ), exit, err… in UDPEndRecv()
3334 sock->overlapped.dstAddr.type = mDNSAddrType_IPv6; in UDPEndRecv()
3335 sock->overlapped.dstAddr.ip.v6 = *( (mDNSv6Addr *) &ipv6PacketInfo->ipi6_addr ); in UDPEndRecv()
3355 …DebugLevelChatty, DEBUG_NAME " src = %#a:%u\n", &sock->overlapped.srcAddr, ntohs( sock->o… in UDPEndRecv()
3356 …DebugLevelChatty, DEBUG_NAME " dst = %#a:%u\n", &sock->overlapped.dstAddr, ntohs( sock->o… in UDPEndRecv()
3358 if ( sock->ifd != NULL ) in UDPEndRecv()
3360 …Chatty, DEBUG_NAME " interface = %#a (index=0x%08X)\n", &sock->ifd->interfaceInfo.ip, sock->ifd… in UDPEndRecv()
3367 AddToTail( &gUDPDispatchableSockets, sock ); in UDPEndRecv()
3839 SOCKET sock; in getifaddrs_ipv4() local
3851 sock = INVALID_SOCKET; in getifaddrs_ipv4()
3860 sock = socket( AF_INET, SOCK_DGRAM, IPPROTO_UDP ); in getifaddrs_ipv4()
3861 err = translate_errno( IsValidSocket( sock ), errno_compat(), kUnknownErr ); in getifaddrs_ipv4()
3872 err = WSAIoctl( sock, SIO_GET_INTERFACE_LIST, NULL, 0, buffer, size, &actualSize, NULL, NULL ); in getifaddrs_ipv4()
3976 if( sock != INVALID_SOCKET ) in getifaddrs_ipv4()
3978 closesocket( sock ); in getifaddrs_ipv4()
4161 SocketRef sock; in CanReceiveUnicast() local
4166 sock = socket( AF_INET, SOCK_DGRAM, IPPROTO_UDP ); in CanReceiveUnicast()
4167 check_translated_errno( IsValidSocket( sock ), errno_compat(), kUnknownErr ); in CanReceiveUnicast()
4168 ok = IsValidSocket( sock ); in CanReceiveUnicast()
4176 ok = ( bind( sock, (struct sockaddr *) &addr, sizeof( addr ) ) == 0 ); in CanReceiveUnicast()
4177 close_compat( sock ); in CanReceiveUnicast()
4507 TCPCloseSocket( TCPSocket * sock ) in TCPCloseSocket() argument
4509 dlog( kDebugLevelChatty, DEBUG_NAME "closing TCPSocket 0x%x:%d\n", sock, sock->fd ); in TCPCloseSocket()
4511 RemoveFromList( &gTCPDispatchableSockets, sock ); in TCPCloseSocket()
4513 if ( sock->fd != INVALID_SOCKET ) in TCPCloseSocket()
4515 closesocket( sock->fd ); in TCPCloseSocket()
4516 sock->fd = INVALID_SOCKET; in TCPCloseSocket()
4526 TCPFreeSocket( TCPSocket *sock ) in TCPFreeSocket() argument
4528 check( sock ); in TCPFreeSocket()
4530 dlog( kDebugLevelChatty, DEBUG_NAME "freeing TCPSocket 0x%x:%d\n", sock, sock->fd ); in TCPFreeSocket()
4532 if ( sock->connectEvent ) in TCPFreeSocket()
4534 CloseHandle( sock->connectEvent ); in TCPFreeSocket()
4535 sock->connectEvent = NULL; in TCPFreeSocket()
4538 if ( sock->fd != INVALID_SOCKET ) in TCPFreeSocket()
4540 closesocket( sock->fd ); in TCPFreeSocket()
4541 sock->fd = INVALID_SOCKET; in TCPFreeSocket()
4544 free( sock ); in TCPFreeSocket()
4553 UDPCloseSocket( UDPSocket * sock ) in UDPCloseSocket() argument
4555 dlog( kDebugLevelChatty, DEBUG_NAME "closing UDPSocket %d\n", sock->fd ); in UDPCloseSocket()
4557 RemoveFromList( &gUDPDispatchableSockets, sock ); in UDPCloseSocket()
4559 if ( sock->fd != INVALID_SOCKET ) in UDPCloseSocket()
4561 closesocket( sock->fd ); in UDPCloseSocket()
4562 sock->fd = INVALID_SOCKET; in UDPCloseSocket()
4572 UDPFreeSocket( UDPSocket * sock ) in UDPFreeSocket() argument
4574 check( sock ); in UDPFreeSocket()
4576 dlog( kDebugLevelChatty, DEBUG_NAME "freeing UDPSocket %d\n", sock->fd ); in UDPFreeSocket()
4578 if ( sock->fd != INVALID_SOCKET ) in UDPFreeSocket()
4580 closesocket( sock->fd ); in UDPFreeSocket()
4581 sock->fd = INVALID_SOCKET; in UDPFreeSocket()
4584 free( sock ); in UDPFreeSocket()
5144 DispatchUDPEvent( mDNS * const inMDNS, UDPSocket * sock ) in DispatchUDPEvent() argument
5152 if ( sock->fd != INVALID_SOCKET ) in DispatchUDPEvent()
5154 const mDNSInterfaceID iid = sock->ifd ? sock->ifd->interfaceInfo.InterfaceID : NULL; in DispatchUDPEvent()
5155 mDNSu8 * end = ( (mDNSu8 *) &sock->packet ) + sock->overlapped.bytesTransferred; in DispatchUDPEvent()
5157 dlog( kDebugLevelChatty, DEBUG_NAME "calling mDNSCoreReceive on socket: %d\n", sock->fd ); in DispatchUDPEvent()
5158 …mDNSCoreReceive( sock->m, &sock->packet, end, &sock->overlapped.srcAddr, sock->overlapped.srcPort,… in DispatchUDPEvent()
5163 if ( sock->fd != INVALID_SOCKET ) in DispatchUDPEvent()
5165 int err = UDPBeginRecv( sock ); in DispatchUDPEvent()
5172 DispatchTCPEvent( mDNS * const inMDNS, TCPSocket * sock ) in DispatchTCPEvent() argument
5176 if ( sock->fd != INVALID_SOCKET ) in DispatchTCPEvent()
5178 sock->eptr += sock->overlapped.bytesTransferred; in DispatchTCPEvent()
5179 sock->lastError = sock->overlapped.error; in DispatchTCPEvent()
5181 if ( !sock->overlapped.error && !sock->overlapped.bytesTransferred ) in DispatchTCPEvent()
5183 sock->closed = TRUE; in DispatchTCPEvent()
5186 if ( sock->readEventHandler != NULL ) in DispatchTCPEvent()
5188 dlog( kDebugLevelChatty, DEBUG_NAME "calling TCP read handler on socket: %d\n", sock->fd ); in DispatchTCPEvent()
5189 sock->readEventHandler( sock ); in DispatchTCPEvent()
5195 if ( !sock->closed && ( sock->fd != INVALID_SOCKET ) ) in DispatchTCPEvent()
5197 int err = TCPBeginRecv( sock ); in DispatchTCPEvent()