Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Get connection IPs from http::daemon server?

Status
Not open for further replies.

BlakeEM

Programmer
Jan 24, 2006
4
0
0
US
I have a server that uses http::daemon to accept requests. I need a way to get the IP of the users connecting to the http::daemon but I can't seem to find out how to do this. Another way might be to some how get the IP of the user connected to the port that the http:daemon is on but I haven't been able to find anything on this either.

Thanks for any help!

~Blake
 
Have you tried $ENV{'REMOTE_ADDR'}? This is assuming that HTTP::Daemon is providing the same functionality of a webserver

Shelling a `netstat` command in backticks might give you the connections established at a point in time, but you could miss something

HTH
--Paul

Spend an hour a week on CPAN, helps cure all known programming ailments ;-)
 
I tried the $ENV{'REMOTE_ADDR'} but doesn't work.

It seems their has to be some sort of command to get it.

~Blake
 
Ahh I found it after looking around all over. For anyone curious...

$other_end = getpeername($c);
($port, $iaddr) = unpack_sockaddr_in($other_end);
$ip_address = inet_ntoa($iaddr);

$c is from accept() when you get the connection.

~Blake
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top