Created
November 25, 2013 06:28
-
-
Save carlosmcevilly/7637145 to your computer and use it in GitHub Desktop.
check whether Nagle's algorithm is on or off
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/perl | |
# modified from the broken 'perldoc perlfunc' getsockopt example by adding one line (see comment below) | |
use strict; | |
use warnings; | |
use Socket qw(:all); | |
defined(my $tcp = getprotobyname("tcp")) | |
or die "Could not determine the protocol number for tcp"; | |
socket(my $socket, PF_INET, SOCK_STREAM, 0) | |
or die "socket: $!"; # added this line | |
# my $tcp = IPPROTO_TCP; # Alternative | |
my $packed = getsockopt($socket, $tcp, TCP_NODELAY) | |
or die "getsockopt TCP_NODELAY: $!"; | |
my $nodelay = unpack("I", $packed); | |
print "Nagle's algorithm is turned ", $nodelay ? "off\n" : "on\n"; | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment