in reply to Re: Client Server
in thread Client Server

Im trying to write the value of the connected IP to the server drive. I have the file handle set but how to I quantify the IP as a var to pass it to the file handle?

Replies are listed 'Best First'.
Re^3: Client Server
by AppleFritter (Vicar) on Jul 15, 2014 at 18:11 UTC

    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.

      This is what I needed I wasn't sure how to qualify the IP as a variable this did the trick.

      my $ip_address = inet_ntoa($iaddr);