Changeset 7390 for code/branches/ipv6/src/external/enet/patches/0004-using-two-separate-sockets-for-IPv4-and-IPv6.patch
- Timestamp:
- Sep 9, 2010, 4:30:50 PM (14 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
code/branches/ipv6/src/external/enet/patches/0004-using-two-separate-sockets-for-IPv4-and-IPv6.patch
r7389 r7390 1 From 9801a6bcd072870248a6b07245fc09a9492f8f51Mon Sep 17 00:00:00 20011 From 73fa28a84ce456561d3912578121a30bc8263c50 Mon Sep 17 00:00:00 2001 2 2 From: Adrian Friedli <adi@koalatux.ch> 3 3 Date: Wed, 8 Sep 2010 12:50:04 +0200 4 Subject: [PATCH 4/ 4] using two separate sockets for IPv4 and IPv64 Subject: [PATCH 4/5] using two separate sockets for IPv4 and IPv6 5 5 6 6 --- 7 host.c | 53 +++++++++++++++++++++++++++ ++++++++++-------------8 include/enet/enet.h | 11 ++++++ ++-9 protocol.c | 47 ++++++++++++++++++++++++++++ +++++++++++-----10 unix.c | 47 ++++++++++++++++++++++++++++++++------------11 4 files changed, 1 23 insertions(+), 35deletions(-)7 host.c | 53 +++++++++++++++++++++++++++--------- 8 include/enet/enet.h | 11 ++++++- 9 protocol.c | 47 ++++++++++++++++++++++++++++---- 10 unix.c | 74 +++++++++++++++++++++++++++++++++++++------------- 11 4 files changed, 144 insertions(+), 41 deletions(-) 12 12 13 13 diff --git a/host.c b/host.c … … 233 233 host -> serviceTime = enet_time_get (); 234 234 diff --git a/unix.c b/unix.c 235 index 13a24d8..22ffb76100644235 index 475c6e3..751cb6f 100644 236 236 --- a/unix.c 237 237 +++ b/unix.c 238 @@ -11 7,7 +117,9 @@ static int238 @@ -116,7 +116,9 @@ static int 239 239 enet_address_set_sin (struct sockaddr * sin, const ENetAddress * address, ENetAddressFamily family) 240 240 { … … 247 247 ((struct sockaddr_in *) sin) -> sin_family = AF_INET; 248 248 ((struct sockaddr_in *) sin) -> sin_addr = * (struct in_addr *) & address -> host.addr[12]; 249 @@ -21 9,7 +221,7 @@ enet_socket_create (ENetSocketType type, ENetAddressFamily family)249 @@ -218,7 +220,7 @@ enet_socket_create (ENetSocketType type, ENetAddressFamily family) 250 250 #ifdef IPV6_V6ONLY 251 251 if (family == ENET_IPV6) … … 256 256 } 257 257 #endif // IPV6_V6ONLY 258 @@ -39 3,22 +395,38 @@ enet_socketset_select (ENetSocket maxSocket, ENetSocketSet * readSet, ENetSocket258 @@ -392,22 +394,38 @@ enet_socketset_select (ENetSocket maxSocket, ENetSocketSet * readSet, ENetSocket 259 259 } 260 260 … … 263 263 +enet_socket_wait (ENetSocket socket4, ENetSocket socket6, enet_uint32 * condition, enet_uint32 timeout) 264 264 { 265 -#ifdef HAS_POLL265 #ifdef HAS_POLL 266 266 - struct pollfd pollSocket; 267 +//#ifdef HAS_POLL268 267 + struct pollfd pollSocket[2]; 269 268 int pollCount; … … 304 303 if (pollCount < 0) 305 304 return -1; 306 @@ -41 8,13 +436,15@@ enet_socket_wait (ENetSocket socket, enet_uint32 * condition, enet_uint32 timeou305 @@ -417,10 +435,10 @@ enet_socket_wait (ENetSocket socket, enet_uint32 * condition, enet_uint32 timeou 307 306 if (pollCount == 0) 308 307 return 0; … … 317 316 318 317 return 0; 319 +/* 320 +FIXME: implement or remove this 321 #else 322 fd_set readSet, writeSet; 323 struct timeval timeVal; 324 @@ -460,6 +480,7 @@ enet_socket_wait (ENetSocket socket, enet_uint32 * condition, enet_uint32 timeou 318 @@ -436,12 +454,28 @@ enet_socket_wait (ENetSocket socket, enet_uint32 * condition, enet_uint32 timeou 319 FD_ZERO (& writeSet); 320 321 if (* condition & ENET_SOCKET_WAIT_SEND) 322 - FD_SET (socket, & writeSet); 323 + { 324 + if (socket4 != ENET_SOCKET_NULL) 325 + FD_SET (socket4, & writeSet); 326 + if (socket6 != ENET_SOCKET_NULL) 327 + FD_SET (socket6, & writeSet); 328 + } 329 330 if (* condition & ENET_SOCKET_WAIT_RECEIVE) 331 - FD_SET (socket, & readSet); 332 + { 333 + if (socket4 != ENET_SOCKET_NULL) 334 + FD_SET (socket4, & readSet); 335 + if (socket6 != ENET_SOCKET_NULL) 336 + FD_SET (socket6, & readSet); 337 + } 338 + 339 + ENetSocket maxSocket = 0; 340 + if (socket4 != ENET_SOCKET_NULL) 341 + maxSocket = socket4; 342 + if (socket6 != ENET_SOCKET_NULL && socket6 > maxSocket) 343 + maxSocket = socket6; 344 345 - selectCount = select (socket + 1, & readSet, & writeSet, NULL, & timeVal); 346 + selectCount = select (maxSocket + 1, & readSet, & writeSet, NULL, & timeVal); 347 348 if (selectCount < 0) 349 return -1; 350 @@ -451,11 +485,13 @@ enet_socket_wait (ENetSocket socket, enet_uint32 * condition, enet_uint32 timeou 351 if (selectCount == 0) 352 return 0; 353 354 - if (FD_ISSET (socket, & writeSet)) 355 - * condition |= ENET_SOCKET_WAIT_SEND; 356 + if ( (socket4 != ENET_SOCKET_NULL && FD_ISSET (socket4, & writeSet)) || 357 + (socket6 != ENET_SOCKET_NULL && FD_ISSET (socket6, & writeSet)) ) 358 + * condition |= ENET_SOCKET_WAIT_SEND; 359 360 - if (FD_ISSET (socket, & readSet)) 361 - * condition |= ENET_SOCKET_WAIT_RECEIVE; 362 + if ( (socket4 != ENET_SOCKET_NULL && FD_ISSET (socket4, & readSet)) || 363 + (socket6 != ENET_SOCKET_NULL && FD_ISSET (socket6, & readSet)) ) 364 + * condition |= ENET_SOCKET_WAIT_RECEIVE; 325 365 326 366 return 0; 327 #endif328 +*/329 }330 331 367 #endif 332 368 --
Note: See TracChangeset
for help on using the changeset viewer.