From 85271f2e7e0c78167288676982366eaafbe4368b Mon Sep 17 00:00:00 2001 From: oy Date: Sun, 24 Feb 2013 17:14:55 +0100 Subject: [PATCH] increased recv buffer size on windows --- src/base/system.c | 28 ++++++++++++++++------------ 1 file changed, 16 insertions(+), 12 deletions(-) diff --git a/src/base/system.c b/src/base/system.c index ed0f41ec4..7f98efe1a 100644 --- a/src/base/system.c +++ b/src/base/system.c @@ -903,6 +903,7 @@ NETSOCKET net_udp_create(NETADDR bindaddr) NETSOCKET sock = invalid_socket; NETADDR tmpbindaddr = bindaddr; int broadcast = 1; + int recvsize = 65536; if(bindaddr.type&NETTYPE_IPV4) { @@ -917,13 +918,13 @@ NETSOCKET net_udp_create(NETADDR bindaddr) { sock.type |= NETTYPE_IPV4; sock.ipv4sock = socket; + + /* set boardcast */ + setsockopt(socket, SOL_SOCKET, SO_BROADCAST, (const char*)&broadcast, sizeof(broadcast)); + + /* set receive buffer size */ + setsockopt(socket, SOL_SOCKET, SO_RCVBUF, (char*)&recvsize, sizeof(recvsize)); } - - /* set non-blocking */ - net_set_non_blocking(sock); - - /* set boardcast */ - setsockopt(socket, SOL_SOCKET, SO_BROADCAST, (const char*)&broadcast, sizeof(broadcast)); } if(bindaddr.type&NETTYPE_IPV6) @@ -939,15 +940,18 @@ NETSOCKET net_udp_create(NETADDR bindaddr) { sock.type |= NETTYPE_IPV6; sock.ipv6sock = socket; + + /* set boardcast */ + setsockopt(socket, SOL_SOCKET, SO_BROADCAST, (const char*)&broadcast, sizeof(broadcast)); + + /* set receive buffer size */ + setsockopt(socket, SOL_SOCKET, SO_RCVBUF, (char*)&recvsize, sizeof(recvsize)); } - - /* set non-blocking */ - net_set_non_blocking(sock); - - /* set boardcast */ - setsockopt(socket, SOL_SOCKET, SO_BROADCAST, (const char*)&broadcast, sizeof(broadcast)); } + /* set non-blocking */ + net_set_non_blocking(sock); + /* return */ return sock; }