in reply to thread failed to start?

I wrote an custom multithreaded SMTP server with perl and used a program called postal to benchmark it.

I was able to get about 4,000 SMTP transactions per minute from a local network by 'pre-sporking' threads to sit and listen on sockets:

use strict; use threads; use IO::Socket; # the port to listen on: my $PORT = 8989; # the number of threads to pre-spork: my $INITHREADS = 5; my $handle = IO::Socket::INET->new( LocalPort => $PORT, MultiHomed => 1, Type => SOCK_STREAM, Reuse => 1, Listen => 10) or die "Cannot open port $PORT: $!\n"; $handle->autoflush(1); for(1..$INITHREADS) { my $thr = threads->new(\&process)->detach(); } sleep(); # The parent thread sleeps forever. . . # You can potentially change this perma-sleep to # have the parent thread do dynamic thread management # but only if you don't detach() them. sub process { while(my $socklet = $handle->accept()) { # if you want to capture the IP address: # my $peerhost = $socklet->peerhost(); # Here you can do your stuff # I have the server talk to the client # via print $socklet and while(<$socklet>) } }

Replies are listed 'Best First'.
Re: Re: thread failed to start?
by noslenj123 (Scribe) on Mar 10, 2003 at 17:22 UTC
    I kept that code for future testing on the server side.

    However, right now, it's the client side that is having the problem. The server seems to take anything I can throw at it so far with the exception that some connection attempts to it fail, probably because it's just too busy?