Dear Experts
i am trying to get the IP address returned by the API getaddrinfo(). i have no experience with Socket module but i found some code online and giving a try. i use the following code.
#!/usr/bin/perl use Socket; my $server = shift @ARGV; my $pip = gethostbyname($server); my $IP_add = inet_ntoa($pip); print $IP_add;
this returns the IP address of the server passed as argument.
but when i try to print the value of $pip, it returns nothing and if i try to pass the $server directly instead of $pip it gives me error. i am not able to understand when $pip has nothing in it, it works but if i pass $server which has name of server in it it gives error.
could someone explain?
In reply to perl and getaddrinfo API by swissknife
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |