Beefy Boxes and Bandwidth Generously Provided by pair Networks
Clear questions and runnable code
get the best and fastest answer

Getting IP with HTTP::Daemon

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

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


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

    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?

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

How do I use this?Last hourOther CB clients
Other Users?
Others browsing the Monastery: (5)
As of 2024-04-17 08:28 GMT
Find Nodes?
    Voting Booth?

    No recent polls found