Hi All:

lets talk about some of the most poorly documented stuff with respect to
Perl's socket functionality, be it the IO::Socket or just plain socket.

Check this snippet out:
use strict;
use warnings;
use IO::SOcket::INET;
use IO::Socket;
use Socket qw(:all);

my $sock = IO::Socket::INET->new(       Type    =>SOCK_STREAM,
        
Proto   =>'tcp')
        
or die;
my $tcpnodelay = getsockopt($sock,
Socket::IPPROTO_TCP,Socket::TCP_NODELAY) or
                warn("COPuld not query TCP_NODELAY option: $!");
$tcpnodelay = unpack("I", $tcpnodelay);
print("tcpnodelay with getsockopt is $tcpnodelay\n");
$tcpnodelay = $sock->sockopt(Socket::TCP_NODELAY);
print("tcpnodelay is $tcpnodelay\n");

print("Changing with OO meathod\n");
$tcpnodelay = $sock->sockopt(Socket::TCP_NODELAY,1);
$tcpnodelay = getsockopt($sock, Socket::IPPROTO_TCP,Socket::TCP_NODELAY)
or
                warn("COPuld not query TCP_NODELAY option: $!");
$tcpnodelay = unpack("I", $tcpnodelay);
print("tcpnodelay with getsockopt is $tcpnodelay\n");
$tcpnodelay = $sock->sockopt(Socket::TCP_NODELAY);
print("tcpnodelay is $tcpnodelay\n");

I run this and get:
F:\perl\practice\VRS>perl nagel4.pl
tcpnodelay with getsockopt is 0
tcpnodelay is 0
Changing with OO meathod
tcpnodelay with getsockopt is 0
tcpnodelay is 1

Absically means, If I change the TCP_NODELAY flag to on using the OO
interface, only the OO interface interrogation of the flag shows its
changed, if I check with the normal perl function getsockopt, it says
its not changed.

Now look at this snippet:
use strict;
use warnings;
use IO::SOcket::INET;
use IO::Socket;
use Socket qw(:all);

my $sock = IO::Socket::INET->new(       Type    =>SOCK_STREAM,
        
Proto   =>'tcp')
        
or die;
my $tcpnodelay = getsockopt($sock,
Socket::IPPROTO_TCP,Socket::TCP_NODELAY) or
                warn("COPuld not query TCP_NODELAY option: $!");
$tcpnodelay = unpack("I", $tcpnodelay);
print("tcpnodelay with getsockopt is $tcpnodelay\n");
$tcpnodelay = $sock->sockopt(Socket::TCP_NODELAY);
print("tcpnodelay is $tcpnodelay\n");


$tcpnodelay = setsockopt($sock,
Socket::IPPROTO_TCP,Socket::TCP_NODELAY,pack("I",1) );
if($tcpnodelay){
        print("Successfully changed Nagel\n");
} else {
        print("Failed to change Nagel\n");
}
$tcpnodelay = getsockopt($sock, Socket::IPPROTO_TCP,Socket::TCP_NODELAY)
or
                warn("COPuld not query TCP_NODELAY option: $!");
$tcpnodelay = unpack("I", $tcpnodelay);
print("tcpnodelay with getsockopt is $tcpnodelay\n");
$tcpnodelay = $sock->sockopt(Socket::TCP_NODELAY);
print("tcpnodelay is $tcpnodelay\n");

I get this when I run this:
F:\perl\practice\VRS>perl nagel5.pl
tcpnodelay with getsockopt is 0
tcpnodelay is 0
Successfully changed Nagel
tcpnodelay with getsockopt is 1
tcpnodelay is 0

So, when I change the TCP_NODELAY flag using the Perl function
setsockopt, it reports its changed using getsockopt but not using the OO
interface.

Where's the beef?
Did it change or not? Shouldn't both queries of TCP_NODELAY return the
same or is something being chached somewhere? If I change with the OO
method, only the OO method query says its changed, if I change with the
perlfunc then only the perlfunc query says it has been changed, the OO
says its still zero.

Any ideas?

Cheers,
John
        

_______________________________________________
Perl-Win32-Admin mailing list
Perl-Win32-Admin@listserv.ActiveState.com
To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs

Reply via email to