Kristofer Wolff wrote:
> hi, does anybody know a way to find out the server name, or/and the ip
> number ?

What do you mean by that?

> I start a server:
> 
> $server = IO::Socket::INET->new( Proto     => 'tcp',
>                           LocalPort => $PORT,
>                           Listen    => SOMAXCONN,
>                           Reuse     => 1);
> 
> and want to set $this_server = "" // somthing like 
> "ip29.internet-shop.net"
> 
> is it possible to find out the name of the server i generated ?

You want the hostname of the server this socket is on? Well, it's your own
hostname, isn't it? So get the name of your host and you should be fine
(`perldoc -q hostname`). Same with the IP address.

If your machine has multiple IP addresses and/or multiple hostnames, you
have a problem, I suppose. I *believe* (but am not sure) that when you start
a listen socket but don't specify a local address, it binds that port on all
available addresses. If you don't want that, you probably need to add
"LocalAddr => foo.example.com" or "LocalAddr => 10.11.12.13" to your
constructor. I don't think it's possible to bind to more than one IP
address, but not all of them -- I think you just have w.x.y.z or INADDR_ANY
(0.0.0.0).

I'm also not sure what you mean with the "name of the server you generated".
You're listening on a socket now, so I suppose your script is a server. But
what do you mean with its "name"? Some "well-known" services have names,
e.g. 25 = smtp, 23 = telnet, 21 = ftp. But if you use your own port $PORT,
it probably won't have such a name. And the process itself (the server)
doesn't really have a name, either -- just a PID.

Cheers,
Philip
_______________________________________________
Perl-Win32-Web mailing list
[EMAIL PROTECTED]
http://listserv.ActiveState.com/mailman/listinfo/perl-win32-web

Reply via email to