aboutsummaryrefslogtreecommitdiff
path: root/net
diff options
context:
space:
mode:
authorMartin Peach <mrpeach@users.sourceforge.net>2010-05-04 16:07:41 +0000
committerMartin Peach <mrpeach@users.sourceforge.net>2010-05-04 16:07:41 +0000
commit7a9d6e65ebf040aabf24c3f2cdf759837780557b (patch)
tree1f8b553edf4dde1b90f4db0215bc05c8e8740089 /net
parentd86deb5d9767a929df01100f2cd8b1fe56232c6a (diff)
SO_REUSEADDR was not being set on linux.
svn path=/trunk/externals/mrpeach/; revision=13493
Diffstat (limited to 'net')
-rw-r--r--net/tcpserver.c10
1 files changed, 8 insertions, 2 deletions
diff --git a/net/tcpserver.c b/net/tcpserver.c
index 8ecabf0..db7a4b1 100644
--- a/net/tcpserver.c
+++ b/net/tcpserver.c
@@ -913,7 +913,8 @@ static void *tcpserver_new(t_floatarg fportno)
int i;
struct sockaddr_in server;
int sockfd, portno = fportno;
- char optval = 1;
+ int optVal = 1;
+ int optLen = sizeof(int);
/* create a socket */
sockfd = socket(AF_INET, SOCK_STREAM, 0);
@@ -928,7 +929,12 @@ static void *tcpserver_new(t_floatarg fportno)
server.sin_family = AF_INET;
server.sin_addr.s_addr = INADDR_ANY;
/* enable reuse of local address */
- if (setsockopt(sockfd, SOL_SOCKET, SO_REUSEADDR, &optval, sizeof(optval)) < 0)
+#ifdef _WIN32
+ if (setsockopt(sockfd, SOL_SOCKET, SO_SNDBUF, (char*)&optVal, optLen) == SOCKET_ERROR)
+#else
+ if (setsockopt(sockfd, SOL_SOCKET, SO_REUSEADDR, (char*)&optVal, optLen) == -1)
+#endif
+// if (setsockopt(sockfd, SOL_SOCKET, SO_REUSEADDR, &optval, sizeof(optval)) < 0)
sys_sockerror("tcpserver: setsockopt SO_REUSEADDR");
/* assign server port number */