removed Nagle algorithm
This commit is contained in:
parent
0a3cb2d9ee
commit
4df19b472b
3 changed files with 7 additions and 3 deletions
|
@ -1,6 +1,3 @@
|
|||
- remove Nagle algorithm
|
||||
- use TCP_NODELAY
|
||||
|
||||
- support multiple client connections at the same time
|
||||
- first client has control
|
||||
- additional clients can see the traffic
|
||||
|
|
|
@ -5,6 +5,7 @@
|
|||
#include <sys/types.h>
|
||||
#include <sys/socket.h>
|
||||
#include <netinet/in.h>
|
||||
#include <netinet/tcp.h> /* TCP_NODELAY */
|
||||
#include <arpa/inet.h>
|
||||
#include <termios.h>
|
||||
|
||||
|
|
6
server.c
6
server.c
|
@ -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));
|
||||
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 */
|
||||
if (bind(server->socket, (struct sockaddr *) &server->address, sizeof(server->address)) == -1) {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue