in reply to Portably disabling Nagle's algorithm for TCP
Query, set, unset:
(A lot of perl code floating on the internet incorrectly uses SOL_SOCKET as level, possibly because the cookbook gets it wrong).use Socket qw(IPPROTO_TCP TCP_NODELAY); sub nagle(*;$) { my $fh = shift; if (!@_) { return unpack("I", getsockopt($fh, IPPROTO_TCP, TCP_NODELAY) | +| croak "Could not get Nagle state: $!") ? 0 : 1; } if (shift) { setsockopt($fh, IPPROTO_TCP, TCP_NODELAY, 0) || croak "Couldn't enable Nagle's algorithm: $!"; } else { setsockopt($fh, IPPROTO_TCP, TCP_NODELAY,1) || croak "Couldn't disable Nagle's algorithm: $!"; } }
This functionality should only be used if it makes sense though.
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: Portably disabling Nagle's algorithm for TCP
by mowgli (Friar) on Jan 02, 2005 at 22:09 UTC | |
by thospel (Hermit) on Jan 02, 2005 at 23:08 UTC | |
by mowgli (Friar) on Jan 03, 2005 at 17:38 UTC |