p.s. is there a way to ensure that the IO::Socket::INET accept() call will fail if the port is already in use? If I try

my $server = IO::Socket::INET->new(
                                Proto     => 'tcp',
                                LocalPort => 80,
                                Listen    => SOMAXCONN,
                                Reuse     => 1,
                                Timeout   => 10
                                );
$server->accept();

with a Web server already running on my machine and listening on port 80, the code above runs with no error -- it times out after 10 seconds since it can't receive any connections, because the OS is sending all port 80 connections to the Web server. Is there a configuration option I can pass such that accept() will always fail right away because port 80 is in use?

        -Bennett

At 03:08 PM 8/20/2004 -0500, Dirk Bremer \(NISC\) wrote:
----- Original Message -----
From: "Bennett Haselton" <[EMAIL PROTECTED]>
To: <[EMAIL PROTECTED]>
Sent: Friday, August 20, 2004 14:52
Subject: how to do a timeout of accept() in ActivePerl


> However, I'm trying to do something similar in ActivePerl (v5.8.3 build
> 809) but the ActivePerl-Winfaq5.html file says that the alarm() function
is
> not implemented in ActivePerl. So is there a way in ActivePerl to force a
> block of code to time out after a certain number of seconds? This is the
> code that I'm trying to make time out:
>
> my $server = IO::Socket::INET->new( Proto => 'tcp',
> LocalPort => $PORT,
> Listen => SOMAXCONN,
> Reuse => 1);
> $server->accept();
>
> I tried seeing if the accept() function had its own timeout that I could
> use -- this is what the documentation says:
>
> >>>
> accept([PKG])


Bennett,

I do soemthing similar by specifying the Timeout parameter like this:

    my $Socket = IO::Socket::INET->new(LocalHost => $SocketServer,
                                       Listen    => 5,
                                       LocalPort => $Port,
                                       Proto     => 'tcp',
                                       Reuse     => 1,
                                       Timeout   => $Interval);

The value of the variable I am using, i.e. $Interval, can be set to whatever
you desire, it represents the number of seconds that the socket will listen
for a connection.


Dirk Bremer - Systems Programmer II - ESS/AMS  - NISC St. Peters
USA Central Time Zone
636-922-9158 ext. 8652 fax 636-447-4471

[EMAIL PROTECTED]
www.nisc.cc


[EMAIL PROTECTED]     http://www.peacefire.org
(425) 497 9002

_______________________________________________
Perl-Win32-Users mailing list
[EMAIL PROTECTED]
To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs

Reply via email to