jaco has asked for the wisdom of the Perl Monks concerning the following question:
The code which, from what i can tell for IO::Socket looks like thisuse Socket qw( SOCK_DGRAM SOCK_STREAM SOCK_RAW PF_INET SOL_SOCKET inet +_aton inet_ntoa sockaddr_in ); $host="www.cnet.com"; $port="80"; socket(SOCK, PF_INET, SOCK_STREAM, getprotobyname('tcp')); setsockopt(SOCK, SOL_SOCKET, 25 , pack("Z*","eth0")) || die "error\n"; $iaddr = inet_aton($host); $paddr = sockaddr_in($port, $iaddr); connect(SOCK, $paddr);
And this works with ethernet device but NOT PPP.use IO::Socket; $server = $ARGV[0]; $port = 80; $socket = IO::Socket::INET->new( Proto => 'tcp', PeerAddr => $server, PeerPort => $port, Timeout => 10, ); unless($socket) { die("Could not connect to $server:$port"); } $socket->autoflush(1); $socket->sockopt(25, "eth0") || die "error\n";
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Socket, IO::Socket and SO_BINDTODEVICE
by jaco (Pilgrim) on Sep 13, 2003 at 17:07 UTC |