Browse Source

Set send and receive buffers

Georgi Chorbadzhiyski 13 years ago
parent
commit
f811ea985e
1 changed files with 8 additions and 0 deletions
  1. 8
    0
      udp.c

+ 8
- 0
udp.c View File

@@ -23,6 +23,10 @@ int udp_connect_input(struct io *io) {
23 23
 	int on = 1;
24 24
 	setsockopt(sock, SOL_SOCKET, SO_REUSEADDR, &on, sizeof(on));
25 25
 
26
+	/* Set receive buffer size to ~2.3MB or 6Mb/s for half a second */
27
+	int bufsize = (6000000 / 1316) / 2;
28
+	setsockopt(sock, SOL_SOCKET, SO_RCVBUF, (void *)&bufsize, sizeof(bufsize));
29
+
26 30
 	// subscribe to multicast group
27 31
 	if (IN_MULTICAST(ntohl(io->addr.s_addr))) {
28 32
 		struct ip_mreq mreq;
@@ -64,6 +68,10 @@ int udp_connect_output(struct io *io) {
64 68
 	setsockopt(sock, SOL_SOCKET, SO_REUSEADDR, &on, sizeof(on));
65 69
 	set_sock_nonblock(sock);
66 70
 
71
+	/* Set receive buffer size to ~2.3MB or 6Mb/s for half a second */
72
+	int bufsize = (6000000 / 1316) / 2;
73
+	setsockopt(sock, SOL_SOCKET, SO_SNDBUF, (void *)&bufsize, sizeof(bufsize));
74
+
67 75
 	// subscribe to multicast group
68 76
 	if (IN_MULTICAST(ntohl(io->addr.s_addr))) {
69 77
 		int ttl = io->ttl;

Loading…
Cancel
Save