Changeset 7377 for code/branches/ipv6
- Timestamp:
- Sep 8, 2010, 4:08:09 AM (14 years ago)
- Location:
- code/branches/ipv6/src/external/enet
- Files:
-
- 1 added
- 2 deleted
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
code/branches/ipv6/src/external/enet/host.c
r7330 r7377 49 49 memset (host -> peers, 0, peerCount * sizeof (ENetPeer)); 50 50 51 host -> socket = enet_socket_create (ENET_SOCKET_TYPE_DATAGRAM); 52 enet_socket_set_option (host -> socket, ENET_SOCKOPT_V6ONLY, 0); // Needs to be set before bind. 53 54 if (host -> socket == ENET_SOCKET_NULL || (address != NULL && enet_socket_bind (host -> socket, address) < 0)) 55 { 56 if (host -> socket != ENET_SOCKET_NULL) 57 enet_socket_destroy (host -> socket); 51 52 // FIXME: check address for ANY_ADRESS if not only bind to specific protocol 53 // FIXME: allow to fail one of the two protocols 54 /* IPv4 */ 55 host -> socket4 = enet_socket_create (ENET_SOCKET_TYPE_DATAGRAM, ENET_IPV4); 56 if (host -> socket4 == ENET_SOCKET_NULL || (address != NULL && enet_socket_bind (host -> socket4, address, ENET_IPV4) < 0)) 57 { 58 if (host -> socket4 != ENET_SOCKET_NULL) 59 enet_socket_destroy (host -> socket4); 58 60 59 61 enet_free (host -> peers); … … 63 65 } 64 66 65 enet_socket_set_option (host -> socket, ENET_SOCKOPT_NONBLOCK, 1); 66 enet_socket_set_option (host -> socket, ENET_SOCKOPT_BROADCAST, 1); 67 enet_socket_set_option (host -> socket, ENET_SOCKOPT_RCVBUF, ENET_HOST_RECEIVE_BUFFER_SIZE); 68 enet_socket_set_option (host -> socket, ENET_SOCKOPT_SNDBUF, ENET_HOST_SEND_BUFFER_SIZE); 67 enet_socket_set_option (host -> socket4, ENET_SOCKOPT_NONBLOCK, 1); 68 enet_socket_set_option (host -> socket4, ENET_SOCKOPT_BROADCAST, 1); 69 enet_socket_set_option (host -> socket4, ENET_SOCKOPT_RCVBUF, ENET_HOST_RECEIVE_BUFFER_SIZE); 70 enet_socket_set_option (host -> socket4, ENET_SOCKOPT_SNDBUF, ENET_HOST_SEND_BUFFER_SIZE); 71 72 /* IPv6 */ 73 host -> socket6 = enet_socket_create (ENET_SOCKET_TYPE_DATAGRAM, ENET_IPV6); 74 if (host -> socket6 == ENET_SOCKET_NULL || (address != NULL && enet_socket_bind (host -> socket6, address, ENET_IPV6) < 0)) 75 { 76 if (host -> socket6 != ENET_SOCKET_NULL) 77 { 78 enet_socket_destroy (host -> socket4); 79 enet_socket_destroy (host -> socket6); 80 } 81 82 enet_free (host -> peers); 83 enet_free (host); 84 85 return NULL; 86 } 87 88 enet_socket_set_option (host -> socket6, ENET_SOCKOPT_NONBLOCK, 1); 89 enet_socket_set_option (host -> socket6, ENET_SOCKOPT_BROADCAST, 1); 90 enet_socket_set_option (host -> socket6, ENET_SOCKOPT_RCVBUF, ENET_HOST_RECEIVE_BUFFER_SIZE); 91 enet_socket_set_option (host -> socket6, ENET_SOCKOPT_SNDBUF, ENET_HOST_SEND_BUFFER_SIZE); 92 69 93 70 94 if (address != NULL) … … 136 160 ENetPeer * currentPeer; 137 161 138 enet_socket_destroy (host -> socket); 162 enet_socket_destroy (host -> socket4); 163 enet_socket_destroy (host -> socket6); 139 164 140 165 for (currentPeer = host -> peers; -
code/branches/ipv6/src/external/enet/include/enet/enet.h
r7330 r7377 51 51 ENET_SOCKOPT_RCVBUF = 3, 52 52 ENET_SOCKOPT_SNDBUF = 4, 53 ENET_SOCKOPT_REUSEADDR = 5, 54 ENET_SOCKOPT_V6ONLY = 6 53 ENET_SOCKOPT_REUSEADDR = 5 55 54 } ENetSocketOption; 56 55 … … 60 59 } ENetHostAddress; 61 60 62 extern const ENetHostAddress ENET_HOST_ANY; /**< specifies the default server host */ 63 extern const ENetHostAddress ENET_HOST_BROADCAST; /**< specifies a IPv4 subnet-wide broadcast */ 64 #define ENET_PORT_ANY 0 /**< specifies that a port should be automatically chosen */ 61 extern const ENetHostAddress ENET_HOST_ANY; /**< specifies the default server host */ 62 extern const ENetHostAddress ENET_IPV4MAPPED_PREFIX; /**< specifies the IPv4-mapped IPv6 prefix */ 63 extern const ENetHostAddress ENET_HOST_BROADCAST; /**< specifies a IPv4 subnet-wide broadcast */ 64 #define ENET_IPV4MAPPED_PREFIX_LEN 12 /**< specifies the length of the IPv4-mapped IPv6 prefix */ 65 #define ENET_PORT_ANY 0 /**< specifies that a port should be automatically chosen */ 65 66 66 67 /** … … 80 81 enet_uint16 port; 81 82 } ENetAddress; 83 84 /** 85 * The address family type. 86 */ 87 typedef enum _ENetAddressFamily 88 { 89 ENET_NO_ADDRESS_FAMILY = 0, 90 ENET_IPV4 = 1, 91 ENET_IPV6 = 2 92 } ENetAddressFamily; 82 93 83 94 /** … … 325 336 typedef struct _ENetHost 326 337 { 327 ENetSocket socket; 338 ENetSocket socket4; 339 ENetSocket socket6; 328 340 ENetAddress address; /**< Internet address of the host */ 329 341 enet_uint32 incomingBandwidth; /**< downstream bandwidth of the host */ … … 445 457 @{ 446 458 */ 447 ENET_API ENetSocket enet_socket_create (ENetSocketType );448 ENET_API int enet_socket_bind (ENetSocket, const ENetAddress * );459 ENET_API ENetSocket enet_socket_create (ENetSocketType, ENetAddressFamily); 460 ENET_API int enet_socket_bind (ENetSocket, const ENetAddress *, ENetAddressFamily); 449 461 ENET_API int enet_socket_listen (ENetSocket, int); 450 ENET_API ENetSocket enet_socket_accept (ENetSocket, ENetAddress * );451 ENET_API int enet_socket_connect (ENetSocket, const ENetAddress * );452 ENET_API int enet_socket_send (ENetSocket, const ENetAddress *, const ENetBuffer *, size_t );453 ENET_API int enet_socket_receive (ENetSocket, ENetAddress *, ENetBuffer *, size_t );454 ENET_API int enet_socket_wait (ENetSocket, enet_uint32 *, enet_uint32);462 ENET_API ENetSocket enet_socket_accept (ENetSocket, ENetAddress *, ENetAddressFamily); 463 ENET_API int enet_socket_connect (ENetSocket, const ENetAddress *, ENetAddressFamily); 464 ENET_API int enet_socket_send (ENetSocket, const ENetAddress *, const ENetBuffer *, size_t, ENetAddressFamily); 465 ENET_API int enet_socket_receive (ENetSocket, ENetAddress *, ENetBuffer *, size_t, ENetAddressFamily); 466 ENET_API int enet_socket_wait (ENetSocket, ENetSocket, enet_uint32 *, enet_uint32); 455 467 ENET_API int enet_socket_set_option (ENetSocket, ENetSocketOption, int); 456 468 ENET_API void enet_socket_destroy (ENetSocket); … … 496 508 @returns the IPv4-mapped IPv6 address in network byte order 497 509 */ 498 static inline ENetHostAddress enet_address_map4 (enet_uint32 address) 499 { 500 ENetHostAddress addr = ENET_HOST_ANY; 501 ((enet_uint16 *)addr.addr)[5] = 0xffff;502 ((enet_uint32 *)addr.addr)[3] = address;503 return addr; 504 } 510 ENET_API ENetHostAddress enet_address_map4 (enet_uint32 address); 511 512 /** Returns the Address family of an (IPv4-mapped) IPv6 address. 513 @param address IPv6 address 514 @returns address family 515 */ 516 ENET_API ENetAddressFamily enet_get_address_family (const ENetAddress * address); 505 517 506 518 /** @} */ -
code/branches/ipv6/src/external/enet/protocol.c
r7330 r7377 11 11 12 12 const ENetHostAddress ENET_HOST_ANY = { { 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 } }; 13 const ENetHostAddress ENET_IPV4MAPPED_PREFIX = { { 0,0,0,0,0,0,0,0,0,0, 0xff, 0xff, 0,0,0,0 } }; 13 14 const ENetHostAddress ENET_HOST_BROADCAST = { { 0,0,0,0,0,0,0,0,0,0, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff } }; 14 15 … … 28 29 sizeof (ENetProtocolThrottleConfigure), 29 30 }; 31 32 ENetHostAddress 33 enet_address_map4 (enet_uint32 address) 34 { 35 ENetHostAddress addr = ENET_IPV4MAPPED_PREFIX; 36 ((enet_uint32 *)addr.addr)[3] = address; 37 return addr; 38 } 39 40 ENetAddressFamily 41 enet_get_address_family (const ENetAddress * address) 42 { 43 if (!memcmp(& address->host, & ENET_IPV4MAPPED_PREFIX, ENET_IPV4MAPPED_PREFIX_LEN)) 44 return ENET_IPV4; 45 return ENET_IPV6; 46 } 30 47 31 48 size_t … … 1025 1042 1026 1043 static int 1027 enet_protocol_receive_incoming_commands (ENetHost * host, ENetEvent * event )1044 enet_protocol_receive_incoming_commands (ENetHost * host, ENetEvent * event, ENetAddressFamily family) 1028 1045 { 1029 1046 for (;;) … … 1035 1052 buffer.dataLength = sizeof (host -> packetData [0]); 1036 1053 1037 receivedLength = enet_socket_receive ( host -> socket,1054 receivedLength = enet_socket_receive (family == ENET_IPV4 ? host -> socket4 : host -> socket6, 1038 1055 & host -> receivedAddress, 1039 1056 & buffer, 1040 1); 1057 1, 1058 family); 1041 1059 1042 1060 if (receivedLength < 0) … … 1045 1063 if (receivedLength == 0) 1046 1064 return 0; 1065 1066 if (enet_get_address_family (& host -> receivedAddress) != family) 1067 return -1; 1047 1068 1048 1069 host -> receivedData = host -> packetData [0]; … … 1501 1522 currentPeer -> lastSendTime = host -> serviceTime; 1502 1523 1503 sentLength = enet_socket_send (host -> socket, & currentPeer -> address, host -> buffers, host -> bufferCount); 1524 ENetAddressFamily family = enet_get_address_family (& currentPeer -> address); 1525 sentLength = enet_socket_send (family == ENET_IPV4 ? host -> socket4 : host -> socket6, 1526 & currentPeer -> address, 1527 host -> buffers, 1528 host -> bufferCount, 1529 family); 1504 1530 1505 1531 enet_protocol_remove_sent_unreliable_commands (currentPeer); … … 1612 1638 } 1613 1639 1614 switch (enet_protocol_receive_incoming_commands (host, event)) 1640 switch (enet_protocol_receive_incoming_commands (host, event, ENET_IPV4)) 1641 { 1642 case 1: 1643 return 1; 1644 1645 case -1: 1646 perror ("Error receiving incoming packets"); 1647 1648 return -1; 1649 1650 default: 1651 break; 1652 } 1653 1654 switch (enet_protocol_receive_incoming_commands (host, event, ENET_IPV6)) 1615 1655 { 1616 1656 case 1: … … 1664 1704 waitCondition = ENET_SOCKET_WAIT_RECEIVE; 1665 1705 1666 if (enet_socket_wait (host -> socket , & waitCondition, ENET_TIME_DIFFERENCE (timeout, host -> serviceTime)) != 0)1706 if (enet_socket_wait (host -> socket4, host -> socket6, & waitCondition, ENET_TIME_DIFFERENCE (timeout, host -> serviceTime)) != 0) 1667 1707 return -1; 1668 1708 -
code/branches/ipv6/src/external/enet/unix.c
r7330 r7377 72 72 } 73 73 74 static enet_uint16 75 enet_af (ENetAddressFamily family) 76 { 77 if (family == ENET_IPV4) 78 return AF_INET; 79 if (family == ENET_IPV6) 80 return AF_INET6; 81 return 0; 82 } 83 84 static socklen_t 85 enet_sa_size (ENetAddressFamily family) 86 { 87 if (family == ENET_IPV4) 88 return sizeof (struct sockaddr_in); 89 if (family == ENET_IPV6) 90 return sizeof (struct sockaddr_in6); 91 return 0; 92 } 93 94 95 static ENetAddressFamily 96 enet_address_set_address (ENetAddress * address, const struct sockaddr * sin) 97 { 98 memset (address, 0, sizeof (ENetAddress)); 99 if (sin -> sa_family == AF_INET) 100 { 101 address -> host = enet_address_map4 ((((struct sockaddr_in *) sin) -> sin_addr.s_addr)); 102 //address -> scopeID = 0; 103 address -> port = ENET_NET_TO_HOST_16 (((struct sockaddr_in *) sin) -> sin_port); 104 return ENET_IPV4; 105 } 106 if (sin -> sa_family == AF_INET6) 107 { 108 address -> host = * (ENetHostAddress *) & ((struct sockaddr_in6 *) sin) -> sin6_addr; 109 address -> scopeID = ((struct sockaddr_in6 *) sin) -> sin6_scope_id; 110 address -> port = ENET_NET_TO_HOST_16 (((struct sockaddr_in6 *) sin) -> sin6_port); 111 return ENET_IPV6; 112 } 113 return ENET_NO_ADDRESS_FAMILY; 114 } 115 116 static int 117 enet_address_set_sin (struct sockaddr * sin, const ENetAddress * address, ENetAddressFamily family) 118 { 119 memset (sin, 0, enet_sa_size(family)); 120 if (family == ENET_IPV4 && 121 (enet_get_address_family (address) == ENET_IPV4 || 122 !memcmp (address, & ENET_HOST_ANY, sizeof(ENetHostAddress)))) 123 { 124 ((struct sockaddr_in *) sin) -> sin_family = AF_INET; 125 ((struct sockaddr_in *) sin) -> sin_addr = * (struct in_addr *) & address -> host.addr[12]; 126 ((struct sockaddr_in *) sin) -> sin_port = ENET_HOST_TO_NET_16 (address -> port); 127 return 0; 128 } 129 else if (family == ENET_IPV6) 130 { 131 ((struct sockaddr_in6 *) sin) -> sin6_family = AF_INET6; 132 ((struct sockaddr_in6 *) sin) -> sin6_addr = * (struct in6_addr *) & address -> host; 133 ((struct sockaddr_in6 *) sin) -> sin6_scope_id = address -> scopeID; 134 ((struct sockaddr_in6 *) sin) -> sin6_port = ENET_HOST_TO_NET_16 (address -> port); 135 return 0; 136 } 137 return -1; 138 } 139 74 140 int 75 141 enet_address_set_host (ENetAddress * address, const char * name) 76 142 { 143 enet_uint16 port = address -> port; 77 144 struct addrinfo hints; 78 145 struct addrinfo * result; … … 84 151 85 152 if ( getaddrinfo(name, NULL, &hints, &result) ) 86 {87 153 return -1; 88 }89 154 90 155 for (res = result; res != NULL; res = res -> ai_next) 91 156 { 92 if (res -> ai_family == AF_INET) 93 { 94 address -> host = enet_address_map4( ((struct sockaddr_in *) res -> ai_addr ) -> sin_addr.s_addr ); 95 address -> scopeID = 0; 96 break; 97 } 98 if (res -> ai_family == AF_INET6) 99 { 100 address -> host = * (ENetHostAddress *) & ((struct sockaddr_in6 *) res -> ai_addr ) -> sin6_addr; 101 address -> scopeID = ((struct sockaddr_in6 *) res -> ai_addr ) -> sin6_scope_id; 102 break; 103 } 104 } 157 if ( enet_address_set_address(address, res -> ai_addr) != ENET_NO_ADDRESS_FAMILY ) 158 break; 159 } 160 161 address -> port = port; 105 162 freeaddrinfo(result); 106 163 if (res == NULL) return -1; … … 112 169 enet_address_get_host_x (const ENetAddress * address, char * name, size_t nameLength, int flags) 113 170 { 114 struct sockaddr_in6 sin; 115 116 memset (& sin, 0, sizeof (struct sockaddr_in6)); 117 118 sin.sin6_family = AF_INET6; 119 sin.sin6_addr = * (struct in6_addr *) & address -> host; 120 sin.sin6_scope_id = address -> scopeID; 121 122 if ( getnameinfo((struct sockaddr *) & sin, sizeof(sin), name, nameLength, NULL, 0, flags)) 123 { 171 struct sockaddr_storage sin; 172 enet_address_set_sin((struct sockaddr *) & sin, address, ENET_IPV6); 173 174 if ( getnameinfo((struct sockaddr *) & sin, enet_sa_size (ENET_IPV6), name, nameLength, NULL, 0, flags)) 124 175 return -1; 125 }126 176 127 177 return 0; … … 141 191 142 192 int 143 enet_socket_bind (ENetSocket socket, const ENetAddress * address) 144 { 145 struct sockaddr_in6 sin; 146 147 memset (& sin, 0, sizeof (struct sockaddr_in6)); 148 149 sin.sin6_family = AF_INET6; 193 enet_socket_bind (ENetSocket socket, const ENetAddress * address, ENetAddressFamily family) 194 { 195 struct sockaddr_storage sin; 150 196 151 197 if (address != NULL) 152 198 { 153 sin.sin6_port = ENET_HOST_TO_NET_16 (address -> port); 154 sin.sin6_addr = * (struct in6_addr *) & address -> host; 155 sin.sin6_scope_id = address -> scopeID; 199 enet_address_set_sin((struct sockaddr *) & sin, address, family); 156 200 } 157 201 else 158 202 { 159 sin.sin6_port = 0; 160 sin.sin6_addr = in6addr_any; 161 sin.sin6_scope_id = 0; 162 } 163 164 return bind (socket, 165 (struct sockaddr *) & sin, 166 sizeof (struct sockaddr_in6)); 167 } 168 169 int 203 ENetAddress address_ = { ENET_HOST_ANY, 0, 0 }; 204 enet_address_set_sin((struct sockaddr *) & sin, & address_, family); 205 } 206 207 return bind (socket, (struct sockaddr *) & sin, enet_sa_size(family)); 208 } 209 210 int 170 211 enet_socket_listen (ENetSocket socket, int backlog) 171 212 { … … 174 215 175 216 ENetSocket 176 enet_socket_create (ENetSocketType type) 177 { 178 return socket (AF_INET6, type == ENET_SOCKET_TYPE_DATAGRAM ? SOCK_DGRAM : SOCK_STREAM, 0); 217 enet_socket_create (ENetSocketType type, ENetAddressFamily family) 218 { 219 ENetSocket sock = socket (enet_af (family), type == ENET_SOCKET_TYPE_DATAGRAM ? SOCK_DGRAM : SOCK_STREAM, 0); 220 221 #ifdef IPV6_V6ONLY 222 if (family == ENET_IPV6) 223 { 224 int value = 1; 225 setsockopt (sock, IPPROTO_IPV6, IPV6_V6ONLY, & value, sizeof (int)); 226 } 227 #endif // IPV6_V6ONLY 228 229 return sock; 179 230 } 180 231 … … 209 260 break; 210 261 211 case ENET_SOCKOPT_V6ONLY:212 result = setsockopt (socket, IPPROTO_IPV6, IPV6_V6ONLY, (char *) & value, sizeof (int));213 break;214 215 262 default: 216 263 break; … … 220 267 221 268 int 222 enet_socket_connect (ENetSocket socket, const ENetAddress * address) 223 { 224 struct sockaddr_in6 sin; 225 226 memset (& sin, 0, sizeof (struct sockaddr_in6)); 227 228 sin.sin6_family = AF_INET6; 229 sin.sin6_port = ENET_HOST_TO_NET_16 (address -> port); 230 sin.sin6_addr = * (struct in6_addr *) & address -> host; 231 sin.sin6_scope_id = address -> scopeID; 232 233 return connect (socket, (struct sockaddr *) & sin, sizeof (struct sockaddr_in6)); 269 enet_socket_connect (ENetSocket socket, const ENetAddress * address, ENetAddressFamily family) 270 { 271 struct sockaddr_storage sin; 272 enet_address_set_sin((struct sockaddr *) & sin, address, family); 273 274 return connect (socket, (struct sockaddr *) & sin, enet_sa_size (family)); 234 275 } 235 276 236 277 ENetSocket 237 enet_socket_accept (ENetSocket socket, ENetAddress * address )278 enet_socket_accept (ENetSocket socket, ENetAddress * address, ENetAddressFamily family) 238 279 { 239 280 int result; 240 struct sockaddr_ in6sin;241 socklen_t sinLength = sizeof (struct sockaddr_in6);281 struct sockaddr_storage sin; 282 socklen_t sinLength = enet_sa_size (family); 242 283 243 284 result = accept (socket, 244 285 address != NULL ? (struct sockaddr *) & sin : NULL, 245 286 address != NULL ? & sinLength : NULL); 246 287 247 288 if (result == -1) 248 289 return ENET_SOCKET_NULL; … … 250 291 if (address != NULL) 251 292 { 252 address -> host = * (ENetHostAddress *) & sin.sin6_addr; 253 address -> scopeID = sin.sin6_scope_id; 254 address -> port = ENET_NET_TO_HOST_16 (sin.sin6_port); 293 enet_address_set_address(address, (struct sockaddr *) & sin); 255 294 } 256 295 … … 268 307 const ENetAddress * address, 269 308 const ENetBuffer * buffers, 270 size_t bufferCount) 309 size_t bufferCount, 310 ENetAddressFamily family) 271 311 { 272 312 struct msghdr msgHdr; 273 struct sockaddr_ in6sin;313 struct sockaddr_storage sin; 274 314 int sentLength; 275 315 … … 278 318 if (address != NULL) 279 319 { 280 memset (& sin, 0, sizeof (struct sockaddr_in6)); 281 282 sin.sin6_family = AF_INET6; 283 sin.sin6_port = ENET_HOST_TO_NET_16 (address -> port); 284 sin.sin6_addr = * (struct in6_addr *) & address -> host; 285 sin.sin6_scope_id = address -> scopeID; 286 320 enet_address_set_sin((struct sockaddr *) & sin, address, family); 287 321 msgHdr.msg_name = & sin; 288 msgHdr.msg_namelen = sizeof (struct sockaddr_in6);322 msgHdr.msg_namelen = enet_sa_size (family); 289 323 } 290 324 … … 309 343 ENetAddress * address, 310 344 ENetBuffer * buffers, 311 size_t bufferCount) 345 size_t bufferCount, 346 ENetAddressFamily family) 312 347 { 313 348 struct msghdr msgHdr; 314 struct sockaddr_ in6sin;349 struct sockaddr_storage sin; 315 350 int recvLength; 316 351 … … 320 355 { 321 356 msgHdr.msg_name = & sin; 322 msgHdr.msg_namelen = sizeof (struct sockaddr_in6);357 msgHdr.msg_namelen = enet_sa_size (family); 323 358 } 324 359 … … 343 378 if (address != NULL) 344 379 { 345 address -> host = * (ENetHostAddress *) & sin.sin6_addr; 346 address -> scopeID = sin.sin6_scope_id; 347 address -> port = ENET_NET_TO_HOST_16 (sin.sin6_port); 380 enet_address_set_address(address, (struct sockaddr *) & sin); 348 381 } 349 382 … … 363 396 364 397 int 365 enet_socket_wait (ENetSocket socket, enet_uint32 * condition, enet_uint32 timeout) 366 { 367 #ifdef HAS_POLL 368 struct pollfd pollSocket; 398 enet_socket_wait (ENetSocket socket4, ENetSocket socket6, enet_uint32 * condition, enet_uint32 timeout) 399 { 400 //FIXME allow only one of the sockets being available 401 //#ifdef HAS_POLL 402 struct pollfd pollSocket[2]; 369 403 int pollCount; 370 404 371 pollSocket.fd = socket; 372 pollSocket.events = 0; 405 pollSocket[0].fd = socket4; 406 pollSocket[1].fd = socket6; 407 pollSocket[0].events = 0; 408 pollSocket[1].events = 0; 373 409 374 410 if (* condition & ENET_SOCKET_WAIT_SEND) 375 pollSocket.events |= POLLOUT; 411 { 412 pollSocket[0].events |= POLLOUT; 413 pollSocket[1].events |= POLLOUT; 414 } 376 415 377 416 if (* condition & ENET_SOCKET_WAIT_RECEIVE) 378 pollSocket.events |= POLLIN; 379 380 pollCount = poll (& pollSocket, 1, timeout); 417 { 418 pollSocket[0].events |= POLLIN; 419 pollSocket[1].events |= POLLIN; 420 } 421 422 pollCount = poll (pollSocket, 2, timeout); 381 423 382 424 if (pollCount < 0) … … 388 430 return 0; 389 431 390 if ( pollSocket.revents& POLLOUT)432 if ((pollSocket[0].revents | pollSocket[1].revents) & POLLOUT) 391 433 * condition |= ENET_SOCKET_WAIT_SEND; 392 434 393 if ( pollSocket.revents& POLLIN)435 if ((pollSocket[0].revents | pollSocket[1].revents) & POLLIN) 394 436 * condition |= ENET_SOCKET_WAIT_RECEIVE; 395 437 396 438 return 0; 439 /* 440 FIXME: implement this 397 441 #else 398 442 fd_set readSet, writeSet; … … 430 474 return 0; 431 475 #endif 432 } 433 434 #endif 435 476 */ 477 } 478 479 #endif 480
Note: See TracChangeset
for help on using the changeset viewer.