Beefy Boxes and Bandwidth Generously Provided by pair Networks
We don't bite newbies here... much
 
PerlMonks  

Re^4: IO Socket - Detect inbound IP

by Anonymous Monk
on Jan 25, 2011 at 21:27 UTC ( [id://884230]=note: print w/replies, xml ) Need Help??


in reply to Re^3: IO Socket - Detect inbound IP
in thread IO Socket - Detect inbound IP

here it is.
my ($new_sock, $client_addr) = $sock->accept(); my $peerhost = $sock->peeraddr(); my $addr = inet_ntoa($peerhost); print "$addr\n"; print $client_addr\n"; while(<$new_sock>) { print $_; } close($sock);

Replies are listed 'Best First'.
Re^5: IO Socket - Detect inbound IP
by ikegami (Patriarch) on Jan 25, 2011 at 22:17 UTC

    $sock isn't connected to anything. That's why you're getting

    Use of uninitialized value in subroutine entry Bad arg length for Socket::inet_ntoa, length is 0, should be 4

    $! contains the following, but you might not have known that peeraddr sets it on error.

    Transport endpoint is not connected

    You want to know to whom $new_sock is connected.

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://884230]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others examining the Monastery: (4)
As of 2024-04-20 04:05 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found