Skip to content

Commit

Permalink
Use TCP_NOPUSH on OS X and FreeBSD
Browse files Browse the repository at this point in the history
  • Loading branch information
uNetworkingAB authored Jan 8, 2017
1 parent bf78cf7 commit 9f9ae85
Showing 1 changed file with 8 additions and 2 deletions.
10 changes: 8 additions & 2 deletions src/Socket.h
Original file line number Diff line number Diff line change
Expand Up @@ -108,10 +108,16 @@ class WIN32_EXPORT Socket {
Address getAddress();

void cork(int enable) {
#if defined(TCP_CORK)
// Linux & SmartOS have proper TCP_CORK
// Mac OS X & FreeBSD have TCP_NOPUSH which is useless
#ifdef TCP_CORK
setsockopt(getFd(), IPPROTO_TCP, TCP_CORK, &enable, sizeof(int));
#elif defined(TCP_NOPUSH)
// Mac OS X & FreeBSD have TCP_NOPUSH
setsockopt(getFd(), IPPROTO_TCP, TCP_NOPUSH, &enable, sizeof(int));
if (!enable) {
// Tested on OS X, FreeBSD situation is unclear
::send(getFd(), "", 0, MSG_NOSIGNAL);
}
#endif
}

Expand Down

0 comments on commit 9f9ae85

Please sign in to comment.