Beefy Boxes and Bandwidth Generously Provided by pair Networks
Do you know where your variables are?
 
PerlMonks  

Getting IP with HTTP::Daemon

by Anonymous Monk
on Feb 18, 2001 at 01:21 UTC ( #59161=perlquestion: print w/replies, xml ) Need Help??

Anonymous Monk has asked for the wisdom of the Perl Monks concerning the following question:

Hi.

I'm using HTTP::Daemon on Windows 95.

If I use the following: $d->url

HTTP::Daemon will show me the host name of the server with the port number. Example: http://computer:1285/

Isn't there a command, that instead of getting the host name, it will get the IP address of the server?

Ralph :)

Replies are listed 'Best First'.
Re: Getting IP with HTTP::Daemon
by MeowChow (Vicar) on Feb 18, 2001 at 02:11 UTC
    This is a FAQ. Look here.
Re: Getting IP with HTTP::Daemon
by IndyZ (Friar) on Feb 18, 2001 at 01:47 UTC
    First, write or regex to get the hostname, by itself, out of $d->url. I will leave this as a skill building excercise for you. Then, try this:
    use Socket; @addresses = gethostbyname($name) or die "Can't resolve $name: $!\n"; @addresses = map { inet_ntoa($_) } @addresses[4 .. $#addresses];
    @addresses will contain a list of IP addresses. I think that this code is verbatim from the Perl Cookbook, I just copied and pasted it out of an old project of mine.
Re: Getting IP with HTTP::Daemon
by Anonymous Monk on Feb 18, 2001 at 21:42 UTC
    Hi.

    I've tried using the first example and the one's in the FAQ, but they won't work. Many are only for linux, and I'm running it on windows 95.

    The one with the gethostbyname(hostname) just returns a bunch of unreadable symbols.

    Isn't there another way of getting the IP address of the computer?

    Ralph :)

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: perlquestion [id://59161]
Approved by root
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others perusing the Monastery: (3)
As of 2022-09-26 12:11 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    I prefer my indexes to start at:




    Results (117 votes). Check out past polls.

    Notices?