I'm not quite sure what you mean. Could you clarify?
Suppose that you've got the IP address, as returned by inet_ntoa, saved in a variable (say $ip_address), and suppose that you've got a filehandle for a logfile that's opened for writing (say $logfile_handle), then you can just do this (adding a timestamp as well for good measure):
...
my $ip_address = inet_ntoa($iaddr);
...
say $logfile_handle scalar localtime, " Connection from: $ip_address";
...
Integrating this into the above server example should be straightforward.
|