removed Nagle algorithm

This commit is contained in:
Igor Socec 2014-03-06 13:32:48 +01:00
parent 0a3cb2d9ee
commit 4df19b472b
3 changed files with 7 additions and 3 deletions

View file

@ -1,6 +1,3 @@
- remove Nagle algorithm
- use TCP_NODELAY
- support multiple client connections at the same time - support multiple client connections at the same time
- first client has control - first client has control
- additional clients can see the traffic - additional clients can see the traffic

View file

@ -5,6 +5,7 @@
#include <sys/types.h> #include <sys/types.h>
#include <sys/socket.h> #include <sys/socket.h>
#include <netinet/in.h> #include <netinet/in.h>
#include <netinet/tcp.h> /* TCP_NODELAY */
#include <arpa/inet.h> #include <arpa/inet.h>
#include <termios.h> #include <termios.h>

View file

@ -25,6 +25,12 @@ int server_setup(struct server_t *server, unsigned int port) {
fprintf(stderr, "[%s:%d] error %d: %s\n", __func__, __LINE__, errno, strerror(errno)); fprintf(stderr, "[%s:%d] error %d: %s\n", __func__, __LINE__, errno, strerror(errno));
return -errno; return -errno;
} }
/* turn off Nagle algorithm */
opt = 1; /* true value for setsockopt option */
if (setsockopt(server->socket, IPPROTO_TCP, TCP_NODELAY, &opt, sizeof(int)) == -1) {
fprintf(stderr, "[%s:%d] error %d: %s\n", __func__, __LINE__, errno, strerror(errno));
return -errno;
}
/* bind server address to a socket */ /* bind server address to a socket */
if (bind(server->socket, (struct sockaddr *) &server->address, sizeof(server->address)) == -1) { if (bind(server->socket, (struct sockaddr *) &server->address, sizeof(server->address)) == -1) {