File tree Expand file tree Collapse file tree 3 files changed +22
-1
lines changed
Expand file tree Collapse file tree 3 files changed +22
-1
lines changed Original file line number Diff line number Diff line change 1919#include < winsock2.h> // Windows byte-order functions
2020#else
2121#include < arpa/inet.h> // Linux/macOS byte-order functions
22+ #include < netinet/tcp.h>
2223#endif
2324
2425#include < atomic>
Original file line number Diff line number Diff line change @@ -53,7 +53,18 @@ class DMDServerConnector
5353 static DMDServerConnector* Create (const char * pAddress, int port)
5454 {
5555 sockpp::tcp_connector* pConnector = new sockpp::tcp_connector ({pAddress, (in_port_t )port});
56- return pConnector ? new DMDServerConnector (pConnector) : nullptr ;
56+ if (pConnector)
57+ {
58+ int flag = 1 ;
59+ int mss = 1200 ; // Conservative size
60+ int bufsize = 65536 ;
61+ pConnector->set_option (IPPROTO_TCP, TCP_NODELAY, &flag, sizeof (flag));
62+ pConnector->set_option (IPPROTO_TCP, TCP_MAXSEG, &mss, sizeof (mss));
63+ pConnector->set_option (SOL_SOCKET, SO_SNDBUF, &bufsize, sizeof (bufsize));
64+ pConnector->set_option (SOL_SOCKET, SO_RCVBUF, &bufsize, sizeof (bufsize));
65+ return new DMDServerConnector (pConnector);
66+ }
67+ return nullptr ;
5768 }
5869
5970 ssize_t Write (const void * buf, size_t size) { return m_pConnector->write_n (buf, size); }
Original file line number Diff line number Diff line change 22#include < winsock2.h> // Windows byte-order functions
33#else
44#include < arpa/inet.h> // Linux/macOS byte-order functions
5+ #include < netinet/tcp.h>
56#endif
67
78#include < algorithm>
@@ -367,6 +368,14 @@ int main(int argc, char* argv[])
367368 }
368369 else
369370 {
371+ int flag = 1 ;
372+ int mss = 1200 ; // Conservative size
373+ int bufsize = 65536 ;
374+ sock.set_option (IPPROTO_TCP, TCP_NODELAY, &flag, sizeof (flag));
375+ sock.set_option (IPPROTO_TCP, TCP_MAXSEG, &mss, sizeof (mss));
376+ sock.set_option (SOL_SOCKET, SO_SNDBUF, &bufsize, sizeof (bufsize));
377+ sock.set_option (SOL_SOCKET, SO_RCVBUF, &bufsize, sizeof (bufsize));
378+
370379 threadMutex.lock ();
371380 currentThreadId = ++threadId;
372381 threads.push_back (currentThreadId);
You can’t perform that action at this time.
0 commit comments