POSIX::getpeername - provides getpeername(2)
use POSIX::getpeername; use Socket; my $ret = POSIX::getpeername::_getpeername($fd, my $addr); die $! if $ret < 0; my ($peer_port, $peer_iaddr) = sockaddr_in($addr);
POSIX::getpeername provides getpeername(2). perl's core getpeername needs a open file handle. POSIX::getpeername allows you to get peername from sockfd.
The _getpeername() function returns the value 0 if successful; otherwise the value -1 is returned and set errno to $!
POSIX::Socket, Socket
Copyright (C) Masahiro Nagano.
This library is free software; you can redistribute it and/or modify it under the same terms as Perl itself.
Masahiro Nagano <kazeburo@gmail.com>
To install POSIX::getpeername, copy and paste the appropriate command in to your terminal.
cpanm
cpanm POSIX::getpeername
CPAN shell
perl -MCPAN -e shell install POSIX::getpeername
For more information on module installation, please visit the detailed CPAN module installation guide.