http://www.perlmonks.org?node_id=317642


in reply to Net::NNTP ping?

Given that the Net::NNTP module inherits from the IO::Socket class, you may find the connected method inherited from this class to be of use. This method returns the peer address if the socket is in a connected state or an undefined value if the socket is not connected.

For example:

use Net::NNTP; use Socket; my $nntp = Net::NNTP->new('news-server'); my $hostaddr = $nntp->connected; print inet_ntoa((sockaddr_in($hostaddr))[1]), "\n" if defined $hostadd +r;

 

perl -le "print+unpack'N',pack'B32','00000000000000000000001010100100'"