Added NODELAY option to both server and client
This commit is contained in:
@@ -1,4 +1,5 @@
|
||||
#include <netinet/in.h>
|
||||
#include <netinet/tcp.h>
|
||||
#include <arpa/inet.h>
|
||||
#include <string>
|
||||
#include <cstring>
|
||||
@@ -96,6 +97,12 @@ void* IPSocketThread(void* arg)
|
||||
cerr << "Error accepting connection, errno = " << errno << "\n";
|
||||
continue;
|
||||
}
|
||||
int yes = 1;
|
||||
int result = setsockopt(recsock, IPPROTO_TCP, TCP_NODELAY, (char*)&yes, sizeof(int));
|
||||
if (result < 0)
|
||||
{
|
||||
cerr << "Error setting socket option, errno = " << errno << "\n";
|
||||
}
|
||||
cout << "Accepted connection from " << inet_ntoa(peeraddr.sin_addr) << ":" << ntohs(peeraddr.sin_port) << "\n";
|
||||
CreateThread(&ProcessRequests, &recsock);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user