in reply to Re^2: Portably disabling Nagle's algorithm for TCP
in thread Portably disabling Nagle's algorithm for TCP
If you want to check at runtime and e.g. only turn nagle off if the constant really is there, you can check with a string eval, e.g:
(I also didn't try to import it in case you use a Socket.pm that doesn't even have the constant)# untested code use Socket qw(IPPROTO_TCP) my $has_nagle = eval "Socket::TCP_NODELAY(); 1"; ... if ($has_nagle) { setsockopt($fh, IPPROTO_TCP, Socket::TCP_NODELAY(), 1) || croak "Couldn't disable Nagle's algorithm: $!"; } else { warn("Your system doesn't seem to support turning of Nagle's algor +ithm\n"); }
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^4: Portably disabling Nagle's algorithm for TCP
by mowgli (Friar) on Jan 03, 2005 at 17:38 UTC |