Skip to content

Instantly share code, notes, and snippets.

@peczenyj
Last active December 28, 2015 07:38
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save peczenyj/7465389 to your computer and use it in GitHub Desktop.
Save peczenyj/7465389 to your computer and use it in GitHub Desktop.
EDIT: NOT A PROBLEM, I should use TCP_NODELAY with setsockopt. Dammit... Problem: I can't set TCP NODELAY in perl, but I can set with ruby and python. Why? I try with Perl 5.12.2 and 5.18.1!
$ ruby -v
ruby 1.9.3p194 (2012-04-20 revision 35410) [x86_64-linux]
$ perl -v
This is perl 5, version 12, subversion 2 (v5.12.2) built for x86_64-linux
$ python --version
Python 2.7.5+
$ uname -a
Linux tpecze-desktop 3.11.0-12-generic #19-Ubuntu SMP Wed Oct 9 16:20:46 UTC 2013 x86_64 x86_64 x86_64 GNU/Linux
$ ruby z.rb
#<Socket::Option: INET TCP NODELAY 1>
$ python z.py
1
$ perl z.pl
Cannot set tcp nodelay Permission denied (Permission denied) at z.pl line 9.
use Socket qw(TCP_NODELAY IPPROTO_TCP);
use IO::Socket::INET;
my $socket = IO::Socket::INET->new('localhost:8087');
die "Error ($!), can't connect to $host:$port"
unless defined $socket;
$socket->setsockopt(IPPROTO_TCP, TCP_NODELAY, 1)
or die "Cannot set tcp nodelay $! ($^E)";
use Socket qw(TCP_NODELAY);
use IO::Socket::INET;
my $socket = IO::Socket::INET->new('localhost:8087');
die "Error ($!), can't connect to $host:$port"
unless defined $socket;
$socket->sockopt(TCP_NODELAY, 1)
or die "Cannot set tcp nodelay $! ($^E)";
import socket
s = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
s.connect(("localhost",8087))
s.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1)
print s.getsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY)
require 'socket'
s = TCPSocket.new('localhost', 8087)
s.setsockopt(Socket::IPPROTO_TCP, Socket::TCP_NODELAY, 1)
puts s.getsockopt(Socket::IPPROTO_TCP, Socket::TCP_NODELAY).inspect
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment