Skip to content
This repository has been archived by the owner on May 24, 2022. It is now read-only.

Commit

Permalink
Set TCP_NODELAY on backend socket.
Browse files Browse the repository at this point in the history
  • Loading branch information
Jamie Turner committed Oct 13, 2011
1 parent 970b1bc commit 7ad212a
Showing 1 changed file with 9 additions and 3 deletions.
12 changes: 9 additions & 3 deletions stud.c
Expand Up @@ -371,7 +371,13 @@ static int create_back_socket() {


if (s == -1) if (s == -1)
return -1; return -1;


int flag = 1;
int ret = setsockopt(s, IPPROTO_TCP, TCP_NODELAY, (char *)&flag, sizeof(flag));
if (ret == -1) {
perror("Couldn't setsockopt to backend (TCP_NODELAY)\n");
}

int t = 1; int t = 1;
setnonblocking(s); setnonblocking(s);
t = connect(s, backaddr->ai_addr, backaddr->ai_addrlen); t = connect(s, backaddr->ai_addr, backaddr->ai_addrlen);
Expand Down Expand Up @@ -738,13 +744,13 @@ static void handle_accept(struct ev_loop *loop, ev_io *w, int revents) {
int flag = 1; int flag = 1;
int ret = setsockopt(client, IPPROTO_TCP, TCP_NODELAY, (char *)&flag, sizeof(flag) ); int ret = setsockopt(client, IPPROTO_TCP, TCP_NODELAY, (char *)&flag, sizeof(flag) );
if (ret == -1) { if (ret == -1) {
perror("Couldn't setsockopt(TCP_NODELAY)\n"); perror("Couldn't setsockopt on client (TCP_NODELAY)\n");
} }
#ifdef TCP_CWND #ifdef TCP_CWND
int cwnd = 10; int cwnd = 10;
ret = setsockopt(client, IPPROTO_TCP, TCP_CWND, &cwnd, sizeof(cwnd)); ret = setsockopt(client, IPPROTO_TCP, TCP_CWND, &cwnd, sizeof(cwnd));
if (ret == -1) { if (ret == -1) {
perror("Couldn't setsockopt(TCP_CWND)\n"); perror("Couldn't setsockopt on client (TCP_CWND)\n");
} }
#endif #endif


Expand Down

0 comments on commit 7ad212a

Please sign in to comment.