You don't need this sin stuff here. Try your original code, but with the following replacement:
# this:
my $client = gethostbyaddr(inet_aton($addy), AF_INET); # get name
# instead of:
my $client = gethostbyaddr($addy, AF_INET); # get name
It worked for you with the variable not received from the user because you weren't using quote marks, and you were getting a v-string (a deprecated feature, actually). Your luck was that a v-string is a lot like an inet_aton()-ed string :)
Incidentally, why are you using Socket? Unless you want to use low-level stuff for learning or fine control, you are probably better off using IO::Socket. See perlipc, also. |