Hello

I have a server application running on a WinXP Home Edition withSP2. It 
accepts connections, fork to create a child that would deal with the 
connection so the server would be ready to accept new connections. 

The server acts as a fork for POP protocol. it accept connection from a 
client, check it's database for the supplied address and connects to the 
correct POP3 server.

The problem is that the server only work for around 20 connections, after 
that I get the "Can't fork: Resource temporarily unavailable" error. The 
function that does the fork has a exit so it exits from the child but it 
seams that it doesn't clean the resources used. Is there a way to make it 
work in windows?

The $client object does the connection to the client but it doesn't do any 
fork.

This is the function that does the fork:
sub spawn {
  my $self = shift;
  my $sock = shift;
  die "Need a Connection|" unless $sock;
  unless(defined($self->{client})) {
    $self->log("Don't have a client to run!");
    print $sock "-ERR Don't have a client to run!$self->{EOL}";
    return;
  }
  $SIG{CHLD} = 'IGNORE';
  my $kidpid = fork();
  unless(defined($kidpid)) {
    $self->log("-ERR Can't fork: $!");
    print $sock "-ERR Can't fork: $!$self->{EOL}";
    return;
  }
  unless($kidpid) {
    my $client = $self->{client}->clone();
    my @ctime = $self->ctime();
    $self->log("Spawn started at $ctime[6], $ctime[3]/$ctime[4]/$ctime[5] 
$ctime[2]:$ctime[1]:$ctime[0]");
    print $sock $Email::Message::CONNECT;
    $self->login($sock, $client);
    if($sock->connected) {
      $self->log("Spawn connected.");
      $client->Run($sock, $sock);
    }
    $self->log("Spwan died!");
    exit(0);
  }
}

Thanks in advance,
Americo



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

Reply via email to