increased recv buffer size on windows

This commit is contained in:
oy 2013-02-24 17:14:55 +01:00
parent e291a60e7e
commit 85271f2e7e

View file

@ -903,6 +903,7 @@ NETSOCKET net_udp_create(NETADDR bindaddr)
NETSOCKET sock = invalid_socket; NETSOCKET sock = invalid_socket;
NETADDR tmpbindaddr = bindaddr; NETADDR tmpbindaddr = bindaddr;
int broadcast = 1; int broadcast = 1;
int recvsize = 65536;
if(bindaddr.type&NETTYPE_IPV4) if(bindaddr.type&NETTYPE_IPV4)
{ {
@ -917,13 +918,13 @@ NETSOCKET net_udp_create(NETADDR bindaddr)
{ {
sock.type |= NETTYPE_IPV4; sock.type |= NETTYPE_IPV4;
sock.ipv4sock = socket; 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) if(bindaddr.type&NETTYPE_IPV6)
@ -939,15 +940,18 @@ NETSOCKET net_udp_create(NETADDR bindaddr)
{ {
sock.type |= NETTYPE_IPV6; sock.type |= NETTYPE_IPV6;
sock.ipv6sock = socket; 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 */
return sock; return sock;
} }