IPv4 Client
use IO::Socket; use Socket; my $sock = IO::Socket::INET->new( Proto => 'udp', ) or die "Could not create socket: $!\n"; my $pack = pack_sockaddr_in(23456, inet_aton('10.254.83.40')); IO::Socket::send($sock, "message", 0, $pack) or die "Can't send: $!\n" +; print $sock->sockhost(),"\n"; print $sock->sockport(),"\n"; print $sock->peerhost(),"\n"; print $sock->peerport(),"\n";
IPv6 Client
use IO::Socket::INET6; use Socket; use Socket6; my $sock = IO::Socket::INET6->new( Proto => 'udp', ) or die "Could not create socket: $!\n"; my $pack = pack_sockaddr_in6(23456, inet_pton(AF_INET6,'2000:1234:5678 +:9abc::eeff')); IO::Socket::send($sock, "message", 0, $pack) or die "Can't send: $!\n" +; print $sock->sockhost(),"\n"; print $sock->sockport(),"\n"; print $sock->peerhost(),"\n"; print $sock->peerport(),"\n";
IPv4 Output
0.0.0.0 32807 10.254.83.40 23456
IPv6 Output
:: -4622771466457284569 2000:1234:5678:9abc::eeff -4622771466457293920
Question
I can't figure out why INET6 sockets are printing such weird values for the port numbers, even though I'm using the same 23456 in both cases.
In reply to IPv6 Sockets by nitin1704
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |