Skip to content
Snippets Groups Projects
Commit 0ae6709e authored by Micah Elizabeth Scott's avatar Micah Elizabeth Scott
Browse files

Socket options, tcp nodelay & reuseaddr

parent d7fbe4bd
No related branches found
No related tags found
No related merge requests found
......@@ -27,6 +27,8 @@
#include <unistd.h>
#include <string.h>
#include <arpa/inet.h>
#include <netinet/in.h>
#include <netinet/tcp.h>
#include <iostream>
......@@ -41,6 +43,9 @@ void OPCSink::start(struct ev_loop *loop, struct addrinfo *listenAddr)
return;
}
int arg = 1;
setsockopt(sock, SOL_SOCKET, SO_REUSEADDR, &arg, sizeof arg);
if (bind(sock, listenAddr->ai_addr, listenAddr->ai_addrlen)) {
perror("bind");
return;
......@@ -73,6 +78,9 @@ void OPCSink::cbAccept(struct ev_loop *loop, struct ev_io *watcher, int revents)
return;
}
int arg = 1;
setsockopt(sock, IPPROTO_TCP, TCP_NODELAY, &arg, sizeof arg);
Client *cli = new Client();
cli->bufferPos = 0;
cli->self = self;
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment