Setting the TCP_NODELAY option on the socket when available

This commit is contained in:
Pierre Pronchery 2013-01-09 04:09:08 +01:00
parent a1bdfdc71d
commit d56370760b

View File

@ -443,6 +443,11 @@ static int _tcp_socket_init(TCPSocket * tcpsocket, int domain, TCP * tcp)
if((flags & O_NONBLOCK) == 0)
if(fcntl(tcpsocket->fd, F_SETFL, flags | O_NONBLOCK) == -1)
return -_tcp_error("fcntl", 1);
#ifdef TCP_NODELAY
/* do not wait before sending any traffic */
flags = 1;
setsockopt(fd, SOL_SOCKET, TCP_NODELAY, &flags, sizeof(flags));
#endif
return 0;
}