Hi All

Thanks for all your help so far.
I have a problem. I can't seem to fork() more than 64 times.

I found this info from the perl list archive:

"Yes, the number of threads in Perl on Windows is limited to 64.  This is
mostly due to the fact that the Win32 API WaitForMultipleObjects() that is
used to implement the wait() function has a limitation of 64 handles.  One
could extend this by chaining multiple handle blocks, but nobody has done
the work.

Note that we are talking *simultaneous* threads here.  It is possible to
fork() more often than 63 times, but you must reap old threads with wait()
or waitpid().

Cheers,
-Jan
"

Is there any possible trick i can use, so I can fork continuesly?

The script I am using is to test the use of sockets and threads (forks). 
Basically, I would like to get this working so I can incorporate it into a
program I
am working on that will be a Win32 service (or unix Daemon) that checks
many mail (pop3) accounts for new messages at the same time, every few
minutes or seconds. The service should run continuesly. 

So that is the scoop. 

Your help is greatly appreciated. 
Thanks, 

Jer

#####
the following is the is the last bit of output before the program exits

...
in Jon
Forking Jeremy
63
Forking Jon
64
0
Child Jeremy
in Jeremy
0
Child Jon
in Jon
Forking Jeremy
65
Use of uninitialized value in numeric eq (==) at
E:\backup\perlstuff\project\mai
lclient\Emia4Win\Emia4Win-EmiaSVC2003.02.24perlapp-selectslice\pig2.pl line
39.
Use of uninitialized value in concatenation (.) or string at
E:\backup\perlstuff
\project\mailclient\Emia4Win\Emia4Win-EmiaSVC2003.02.24perlapp-selectslice\p
ig2.
pl line 57.
Resource temporarily unavailable
Child Jeremy
in Jeremy
...........

Below is my test code.

#---------------------------------------------------------------------------
---------------------------------------------
use IO::Socket qw(:DEFAULT :crlf);
use strict;
use warnings;


my $pop3C;
my @thr = ();
my @Data = (
         { 'UID' => "Jerdoe", 'SVR' => "mail.host.com", 'PORT' => "110",
'LOGIN' => "jerdoe", 'PASS' => "****" },
         { 'UID' => "Jondoe", 'SVR' => "mail.host.net", 'PORT' => "110",
'LOGIN' => "jondoe", 'PASS' => "**********" },
);
#my $i = 0;

Startup();




sub Startup {
        $| = 0;
        my $i = 0;
        for (;;) 
        {
                foreach my $account (@Data) 
                {
                        if (-f $account->{'UID'}.".acc") 
                        {
                                next;
                        }
                        print "Forking $account->{UID}\n";
                        eval{                           
                                $i++;
                                print "$i\n";   
                                if ((my $pid = fork()) == 0)
                                {
                                        if (!defined $pid)
                                        {
                                                print $!;
                                        }

                                        print "$pid\n";
                                        print "Child $account->{UID}\n";
                                        go($account);
                                        $account = undef;
                                        exit(0);
                                }
                                                
                }
               }

              sleep(1);           
        }
  }



sub go() {
        my $ac = shift;
open(X,">".$ac->{UID}.".acc");
$pop3C = IO::Socket::INET->new(Proto => 'tcp', PeerAddr =>
$ac->{SVR},PeerPort => $ac->{PORT} , Timeout => 0) or pop3CError
($ac->{SVR},$ac->{PORT});
print "in $ac->{UID}\n";
close(X);
$pop3C->close;
unlink($ac->{'UID'}.".acc");
$ac->{'UID'} = undef;
$ac->{'SVR'} = undef;
$ac->{'PORT'} = undef;
$ac->{'LOGIN'} = undef;
$ac->{'PASS'} = undef;
$pop3C = undef;
}

sub pop3CError ($$) {
close(X);
print "Cannot connect to the the Pop3 server:$_[0], port:$_[1]\n";
exit;

}

#---------------------------------------------------------------------------
--------------------------------------------------------------


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

Reply via email to