in reply to Re^2: IO Socket - Detect inbound IP
in thread IO Socket - Detect inbound IP
The 'address' return by accept is actually a packed sockaddr_in struct.
It can be unpacked using the functions sockaddr_in() and then the inet_ntoa() functions as shown in perlipc server example (which is linked from the perlfunc description of accept):
for ( ; $paddr = accept(Client,Server); close Client) { my($port,$iaddr) = sockaddr_in($paddr); my $name = gethostbyaddr($iaddr,AF_INET); logmsg "connection from $name [", inet_ntoa($iaddr), "] at por +t $port";
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^4: IO Socket - Detect inbound IP
by sans-clue (Beadle) on Jan 25, 2011 at 21:32 UTC |