From 83e1204a98488d3f193f870a1caa4891439e841b Mon Sep 17 00:00:00 2001 From: Lee Salzman Date: Wed, 3 Oct 2007 04:07:03 +0000 Subject: [PATCH] *** empty log message *** git-svn-id: svn://svn.code.sf.net/p/actiongame/code/trunk/ac@1338 e016b1c5-ed68-44aa-a2f7-31cac88cffde --- source/enet/configure | 20 ++++++------- source/enet/configure.in | 4 +-- source/enet/host.c | 5 ++++ source/enet/include/enet/enet.h | 9 ++++++ source/enet/unix.c | 51 +++++++++++++++++++++------------ source/enet/win32.c | 44 +++++++++++++++++++--------- 6 files changed, 89 insertions(+), 44 deletions(-) diff --git a/source/enet/configure b/source/enet/configure index addadbe7..424f9e27 100755 --- a/source/enet/configure +++ b/source/enet/configure @@ -1,6 +1,6 @@ #! /bin/sh # Guess values for system-dependent variables and create Makefiles. -# Generated by GNU Autoconf 2.61 for libenet 8-31-2007. +# Generated by GNU Autoconf 2.61 for libenet 10-02-2007. # # Copyright (C) 1992, 1993, 1994, 1995, 1996, 1998, 1999, 2000, 2001, # 2002, 2003, 2004, 2005, 2006 Free Software Foundation, Inc. @@ -572,8 +572,8 @@ SHELL=${CONFIG_SHELL-/bin/sh} # Identity of this package. PACKAGE_NAME='libenet' PACKAGE_TARNAME='libenet' -PACKAGE_VERSION='8-31-2007' -PACKAGE_STRING='libenet 8-31-2007' +PACKAGE_VERSION='10-02-2007' +PACKAGE_STRING='libenet 10-02-2007' PACKAGE_BUGREPORT='' ac_subst_vars='SHELL @@ -1168,7 +1168,7 @@ if test "$ac_init_help" = "long"; then # Omit some internal or obsolete options to make the list less imposing. # This message is too long to be a string in the A/UX 3.1 sh. cat <<_ACEOF -\`configure' configures libenet 8-31-2007 to adapt to many kinds of systems. +\`configure' configures libenet 10-02-2007 to adapt to many kinds of systems. Usage: $0 [OPTION]... [VAR=VALUE]... @@ -1234,7 +1234,7 @@ fi if test -n "$ac_init_help"; then case $ac_init_help in - short | recursive ) echo "Configuration of libenet 8-31-2007:";; + short | recursive ) echo "Configuration of libenet 10-02-2007:";; esac cat <<\_ACEOF @@ -1318,7 +1318,7 @@ fi test -n "$ac_init_help" && exit $ac_status if $ac_init_version; then cat <<\_ACEOF -libenet configure 8-31-2007 +libenet configure 10-02-2007 generated by GNU Autoconf 2.61 Copyright (C) 1992, 1993, 1994, 1995, 1996, 1998, 1999, 2000, 2001, @@ -1332,7 +1332,7 @@ cat >config.log <<_ACEOF This file contains any messages produced by compilers while running configure, to aid debugging if configure makes a mistake. -It was created by libenet $as_me 8-31-2007, which was +It was created by libenet $as_me 10-02-2007, which was generated by GNU Autoconf 2.61. Invocation command line was $ $0 $@ @@ -2002,7 +2002,7 @@ fi # Define the identity of the package. PACKAGE=libenet.a - VERSION=8-31-2007 + VERSION=10-02-2007 cat >>confdefs.h <<_ACEOF @@ -4929,7 +4929,7 @@ exec 6>&1 # report actual input values of CONFIG_FILES etc. instead of their # values after options handling. ac_log=" -This file was extended by libenet $as_me 8-31-2007, which was +This file was extended by libenet $as_me 10-02-2007, which was generated by GNU Autoconf 2.61. Invocation command line was CONFIG_FILES = $CONFIG_FILES @@ -4976,7 +4976,7 @@ Report bugs to ." _ACEOF cat >>$CONFIG_STATUS <<_ACEOF ac_cs_version="\\ -libenet config.status 8-31-2007 +libenet config.status 10-02-2007 configured by $0, generated by GNU Autoconf 2.61, with options \\"`echo "$ac_configure_args" | sed 's/^ //; s/[\\""\`\$]/\\\\&/g'`\\" diff --git a/source/enet/configure.in b/source/enet/configure.in index 458e074c..8c56af63 100755 --- a/source/enet/configure.in +++ b/source/enet/configure.in @@ -1,5 +1,5 @@ -AC_INIT(libenet, 8-31-2007) -AM_INIT_AUTOMAKE(libenet.a, 8-31-2007) +AC_INIT(libenet, 10-02-2007) +AM_INIT_AUTOMAKE(libenet.a, 10-02-2007) AC_PROG_CC AC_PROG_RANLIB diff --git a/source/enet/host.c b/source/enet/host.c index 5633fb9e..603ae323 100755 --- a/source/enet/host.c +++ b/source/enet/host.c @@ -45,6 +45,11 @@ enet_host_create (const ENetAddress * address, size_t peerCount, enet_uint32 inc return NULL; } + enet_socket_set_option (host -> socket, ENET_SOCKOPT_NONBLOCK, 1); + enet_socket_set_option (host -> socket, ENET_SOCKOPT_BROADCAST, 1); + enet_socket_set_option (host -> socket, ENET_SOCKOPT_RCVBUF, ENET_HOST_RECEIVE_BUFFER_SIZE); + enet_socket_set_option (host -> socket, ENET_SOCKOPT_SNDBUF, ENET_HOST_SEND_BUFFER_SIZE); + if (address != NULL) host -> address = * address; diff --git a/source/enet/include/enet/enet.h b/source/enet/include/enet/enet.h index dc415c27..2ba83408 100755 --- a/source/enet/include/enet/enet.h +++ b/source/enet/include/enet/enet.h @@ -41,6 +41,14 @@ typedef enum ENET_SOCKET_WAIT_RECEIVE = (1 << 1) } ENetSocketWait; +typedef enum +{ + ENET_SOCKOPT_NONBLOCK = 1, + ENET_SOCKOPT_BROADCAST = 2, + ENET_SOCKOPT_RCVBUF = 3, + ENET_SOCKOPT_SNDBUF = 4 +} ENetSocketOption; + enum { ENET_HOST_ANY = 0, /**< specifies the default server host */ @@ -394,6 +402,7 @@ ENET_API int enet_socket_connect (ENetSocket, const ENetAddress *); ENET_API int enet_socket_send (ENetSocket, const ENetAddress *, const ENetBuffer *, size_t); ENET_API int enet_socket_receive (ENetSocket, ENetAddress *, ENetBuffer *, size_t); ENET_API int enet_socket_wait (ENetSocket, enet_uint32 *, enet_uint32); +ENET_API int enet_socket_set_option (ENetSocket, ENetSocketOption, int); ENET_API void enet_socket_destroy (ENetSocket); /** @} */ diff --git a/source/enet/unix.c b/source/enet/unix.c index 08ac2491..e279bfeb 100755 --- a/source/enet/unix.c +++ b/source/enet/unix.c @@ -156,30 +156,11 @@ ENetSocket enet_socket_create (ENetSocketType type, const ENetAddress * address) { ENetSocket newSocket = socket (PF_INET, type == ENET_SOCKET_TYPE_DATAGRAM ? SOCK_DGRAM : SOCK_STREAM, 0); - int receiveBufferSize = ENET_HOST_RECEIVE_BUFFER_SIZE, - sendBufferSize = ENET_HOST_SEND_BUFFER_SIZE, - allowBroadcasting = 1; -#ifndef HAS_FCNTL - int nonBlocking = 1; -#endif struct sockaddr_in sin; if (newSocket == ENET_SOCKET_NULL) return ENET_SOCKET_NULL; - if (type == ENET_SOCKET_TYPE_DATAGRAM) - { -#ifdef HAS_FCNTL - fcntl (newSocket, F_SETFL, O_NONBLOCK | fcntl (newSocket, F_GETFL)); -#else - ioctl (newSocket, FIONBIO, & nonBlocking); -#endif - - setsockopt (newSocket, SOL_SOCKET, SO_RCVBUF, (char *) & receiveBufferSize, sizeof (int)); - setsockopt (newSocket, SOL_SOCKET, SO_SNDBUF, (char *) & sendBufferSize, sizeof (int)); - setsockopt (newSocket, SOL_SOCKET, SO_BROADCAST, (char *) & allowBroadcasting, sizeof (int)); - } - if (address == NULL) return newSocket; @@ -204,6 +185,38 @@ enet_socket_create (ENetSocketType type, const ENetAddress * address) return newSocket; } +int +enet_socket_set_option (ENetSocket socket, ENetSocketOption option, int value) +{ + int result = -1; + switch (option) + { + case ENET_SOCKOPT_NONBLOCK: +#ifdef HAS_FCNTL + result = fcntl (socket, F_SETFL, O_NONBLOCK | fcntl (socket, F_GETFL)); +#else + result = ioctl (socket, FIONBIO, & value); +#endif + break; + + case ENET_SOCKOPT_BROADCAST: + result = setsockopt (socket, SOL_SOCKET, SO_BROADCAST, (char *) & value, sizeof (int)); + break; + + case ENET_SOCKOPT_RCVBUF: + result = setsockopt (socket, SOL_SOCKET, SO_RCVBUF, (char *) & value, sizeof (int)); + break; + + case ENET_SOCKOPT_SNDBUF: + result = setsockopt (socket, SOL_SOCKET, SO_SNDBUF, (char *) & value, sizeof (int)); + break; + + default: + break; + } + return result == -1 ? -1 : 0; +} + int enet_socket_connect (ENetSocket socket, const ENetAddress * address) { diff --git a/source/enet/win32.c b/source/enet/win32.c index 95591540..27e78777 100755 --- a/source/enet/win32.c +++ b/source/enet/win32.c @@ -104,24 +104,11 @@ ENetSocket enet_socket_create (ENetSocketType type, const ENetAddress * address) { ENetSocket newSocket = socket (PF_INET, type == ENET_SOCKET_TYPE_DATAGRAM ? SOCK_DGRAM : SOCK_STREAM, 0); - u_long nonBlocking = 1; - int receiveBufferSize = ENET_HOST_RECEIVE_BUFFER_SIZE, - sendBufferSize = ENET_HOST_SEND_BUFFER_SIZE, - allowBroadcasting = 1; struct sockaddr_in sin; if (newSocket == ENET_SOCKET_NULL) return ENET_SOCKET_NULL; - if (type == ENET_SOCKET_TYPE_DATAGRAM) - { - ioctlsocket (newSocket, FIONBIO, & nonBlocking); - - setsockopt (newSocket, SOL_SOCKET, SO_RCVBUF, (char *) & receiveBufferSize, sizeof (int)); - setsockopt (newSocket, SOL_SOCKET, SO_SNDBUF, (char *) & sendBufferSize, sizeof (int)); - setsockopt (newSocket, SOL_SOCKET, SO_BROADCAST, (char *) & allowBroadcasting, sizeof (int)); - } - memset (& sin, 0, sizeof (struct sockaddr_in)); sin.sin_family = AF_INET; @@ -153,6 +140,37 @@ enet_socket_create (ENetSocketType type, const ENetAddress * address) return newSocket; } +int +enet_socket_set_option (ENetSocket socket, ENetSocketOption option, int value) +{ + int result = SOCKET_ERROR; + switch (option) + { + case ENET_SOCKOPT_NONBLOCK: + { + u_long nonBlocking = (u_long) value; + result = ioctlsocket (socket, FIONBIO, & nonBlocking); + break; + } + + case ENET_SOCKOPT_BROADCAST: + result = setsockopt (socket, SOL_SOCKET, SO_BROADCAST, (char *) & value, sizeof (int)); + break; + + case ENET_SOCKOPT_RCVBUF: + result = setsockopt (socket, SOL_SOCKET, SO_RCVBUF, (char *) & value, sizeof (int)); + break; + + case ENET_SOCKOPT_SNDBUF: + result = setsockopt (socket, SOL_SOCKET, SO_SNDBUF, (char *) & value, sizeof (int)); + break; + + default: + break; + } + return result == SOCKET_ERROR ? -1 : 0; +} + int enet_socket_connect (ENetSocket socket, const ENetAddress * address) {