changeset 1515:a7ee9f9a8283

use TCP_NODELAY for DPI communication
author Johannes Hofmann <Johannes.Hofmann@gmx.de>
date Wed, 13 Jan 2010 11:49:21 +0100
parents 239f9fc6c313
children a40980e3eec7
files dpid/dpid.c src/IO/dpi.c
diffstat 2 files changed, 9 insertions(+), 2 deletions(-) [+]
line wrap: on
line diff
--- a/dpid/dpid.c	Tue Jan 12 06:56:01 2010 +0000
+++ b/dpid/dpid.c	Wed Jan 13 11:49:21 2010 +0100
@@ -25,6 +25,7 @@
 #include <sys/stat.h>
 #include <sys/wait.h>
 #include <sys/socket.h>
+#include <netinet/tcp.h>
 
 #include <unistd.h>
 #include "dpid_common.h"
@@ -519,10 +520,13 @@
  */
 static int make_socket_fd()
 {
-   int ret;
+   int ret, one = 1;
 
    if ((ret = socket(AF_INET, SOCK_STREAM, 0)) == -1) {
       ERRMSG("make_socket_fd", "socket", errno);
+   } else {
+      /* avoid delays when sending small pieces of data */
+      setsockopt(ret, IPPROTO_TCP, TCP_NODELAY, &one, sizeof(one));
    }
 
    /* set some buffering to increase the transfer's speed */
--- a/src/IO/dpi.c	Tue Jan 12 06:56:01 2010 +0000
+++ b/src/IO/dpi.c	Wed Jan 13 11:49:21 2010 +0100
@@ -30,6 +30,7 @@
 #include <sys/socket.h>
 #include <sys/un.h>
 #include <netinet/in.h>
+#include <netinet/tcp.h>
 #include <arpa/inet.h>
 #include <netdb.h>
 
@@ -434,9 +435,11 @@
  */
 static int Dpi_make_socket_fd()
 {
-   int fd, ret = -1;
+   int fd, one = 1, ret = -1;
 
    if ((fd = socket(AF_INET, SOCK_STREAM, 0)) != -1) {
+      /* avoid delays when sending small pieces of data */
+      setsockopt(fd, IPPROTO_TCP, TCP_NODELAY, &one, sizeof(one));
       ret = fd;
    }
    return ret;