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

Commit

Permalink
Browse files Browse the repository at this point in the history
Set TCP_NODELAY on backend socket.
  • 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)
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;
setnonblocking(s);
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 ret = setsockopt(client, IPPROTO_TCP, TCP_NODELAY, (char *)&flag, sizeof(flag) );
if (ret == -1) {
perror("Couldn't setsockopt(TCP_NODELAY)\n");
perror("Couldn't setsockopt on client (TCP_NODELAY)\n");
}
#ifdef TCP_CWND
int cwnd = 10;
ret = setsockopt(client, IPPROTO_TCP, TCP_CWND, &cwnd, sizeof(cwnd));
if (ret == -1) {
perror("Couldn't setsockopt(TCP_CWND)\n");
perror("Couldn't setsockopt on client (TCP_CWND)\n");
}
#endif

Expand Down

0 comments on commit 7ad212a

Please sign in to comment.