]> jspc29.x-matter.uni-frankfurt.de Git - daqdata.git/commitdiff
increase socket buffer length to avoid packet loss
authorhadaq <hadaq>
Tue, 6 Jan 2004 10:08:36 +0000 (10:08 +0000)
committerhadaq <hadaq>
Tue, 6 Jan 2004 10:08:36 +0000 (10:08 +0000)
check for success

hadaq/nettrans.c

index f00b18c8fa7007cf24fa23e4926f89f2803a573e..52c87de63d12856a46010a85b543919c17526ac5 100644 (file)
@@ -1,4 +1,4 @@
-static char *rcsId = "$Header: /misc/hadesprojects/daq/cvsroot/eventbuilder/hadaq/nettrans.c,v 6.36 2003-12-09 15:20:53 hadaq Exp $";
+static char *rcsId = "$Header: /misc/hadesprojects/daq/cvsroot/eventbuilder/hadaq/nettrans.c,v 6.37 2004-01-06 10:08:36 hadaq Exp $";
 
 
 #define _GNU_SOURCE
@@ -42,6 +42,22 @@ static int openUdp(NetTrans *my, unsigned long addr, int port, int fl)
        if (-1 == my->fd) {
                retVal = -1;
        } else {
+               int rcvBufLenReq = 1 * (1 << 20);
+               int rcvBufLenRet;
+               int rcvBufLenLen = sizeof(rcvBufLenReq);
+
+               if (setsockopt(my->fd, SOL_SOCKET, SO_RCVBUF, &rcvBufLenReq, rcvBufLenLen) == -1) {
+                       syslog(LOG_WARNING, "setsockopt(..., SO_RCVBUF, ...): %s", strerror(errno));
+               }
+
+               if (getsockopt(my->fd, SOL_SOCKET, SO_RCVBUF, &rcvBufLenRet, &rcvBufLenLen) == -1) {
+                       syslog(LOG_WARNING, "getsockopt(..., SO_RCVBUF, ...): %s", strerror(errno));
+               }
+               if (rcvBufLenRet < rcvBufLenReq) {
+                       syslog(LOG_WARNING, "UDP receive buffer length (%d) smaller than requested buffer length (%d)", rcvBufLenRet,
+                                  rcvBufLenReq);
+               }
+
                my->spec.sa.sin_family = AF_INET;
                my->spec.sa.sin_port = port;
                my->spec.sa.sin_addr.s_addr = htonl(INADDR_ANY);