Thank you all for your replies.

My problem isn't with the connection itself. I can connect without problems. 
The problem is with the fork call. I did a little research and this seams 
to only happen in windows. 

Windows does not support fork, so perl uses threads instead, IThreads to be 
more precise. 
I use a class method to run the server, it works like this:
sub Run {
  my $self = shift;
  while(my $sock = $self->{server}->accept()) {
    print "Server[$$] " if $self->verbose(2);
    my $pid = $self->spawn($sock);
    if($pid == 0) {
      print "Connection ended.\n" if $self->verbose(3);
      return $pid;
    }
  }
}

the spawn method does the fork. if it can't it return 0 and the server 
shutsdown. After about 20 successeful forks, I get "Resource temporarily 
unavailable" error. I've tried waitpid but it didn't work, after several 
forks I still get the same error

this is the fork bit:
  my $kidpid = fork();
  unless(defined($kidpid)) {
    print "-ERR Can't fork: $!\n" if $self->verbose(2);
    $self->log("-ERR Can't fork: $!");
    print $sock "-ERR Can't fork: $!$self->{EOL}";
    my $child;
    while (($child = waitpid(-1,WNOHANG)) > 0) {
      print "Reaping $child\n" if $self->verbose(2);
    }
    return undef;
  }

Am I doing the waitpid in the correct place?

TIA,
Americo





_______________________________________________
ActivePerl mailing list
[email protected]
To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs

Reply via email to