http://qs321.pair.com?node_id=884176

sans-clue has asked for the wisdom of the Perl Monks concerning the following question:

I have searched first, yes. I wish not to pop out to shell (to perform a netstat -an function) in order to glean the remote ip address that is connecting to my simple listener
use IO::Socket; my $sock = new IO::Socket::INET ( LocalHost => 'hosty', LocalPort => '6969', Proto => 'tcp', Listen => 1, Reuse => 1, ); die "Could not create socket: $!\n" unless $sock; my $new_sock = $sock->accept(); while(<$new_sock>) { print $_; } close($sock);
Is there a simple way to get the connecting ip ? I need to look it up in a table to determine what to do next. I currently have a cludgey `netstat -an |grep 6969|grep ESTAB.....` step in there that I'd like to rid of. Thanks