Last active
December 28, 2015 07:38
-
-
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!
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
$ 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 |
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
$ 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. |
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
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)"; |
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
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)"; |
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
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) |
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
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