summaryrefslogtreecommitdiff
path: root/src/clients.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/clients.c')
-rw-r--r--src/clients.c13
1 files changed, 13 insertions, 0 deletions
diff --git a/src/clients.c b/src/clients.c
index e4a7af5..1d529d6 100644
--- a/src/clients.c
+++ b/src/clients.c
@@ -36,6 +36,7 @@
#include <sys/socket.h>
#include <sys/select.h>
#include <netinet/in.h>
+#include <netinet/tcp.h>
#include "clients.h"
#include "tcp.h"
@@ -111,6 +112,18 @@ int clients_add(clients_t* list, int fd, const tcp_endpoint_t remote_end, const
return -1;
}
+ int on = 1;
+ if(setsockopt(element->fd_[0], IPPROTO_TCP, TCP_NODELAY, &on, sizeof(on)) ||
+ setsockopt(element->fd_[1], IPPROTO_TCP, TCP_NODELAY, &on, sizeof(on))) {
+ log_printf(ERROR, "Error on setsockopt(): %s", strerror(errno));
+ free(element->write_buf_[0].buf_);
+ free(element->write_buf_[1].buf_);
+ close(element->fd_[0]);
+ close(element->fd_[1]);
+ free(element);
+ return -1;
+ }
+
if(source_end.addr_.ss_family != AF_UNSPEC) {
if(bind(element->fd_[1], (struct sockaddr *)&(source_end.addr_), source_end.len_)==-1) {
log_printf(INFO, "Error on bind(): %s, not adding client %d", strerror(errno), element->fd_[0]);