# 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 algorithm\n"); }