>
> That's exactly my point. The underlying system seems to make it
> work.
>
> I have not trying to run the code that was posted, that is why I was
> trying to get more info on it.
>
> I think that the thread handling the accepts is the thread that binded
> the socket.
>
> On the other hand all threads may have the correct socket reference,
> which brings up the question as to how the OS signals that the socket
> is already on an accept state, does it wait for it to be released?
>
> Alberto
>
> On Wed, 2003-01-22 at 15:00, Joshua Hoblitt wrote:
> > And what OS are you on? Some platforms (like solaris) only
> allow one process at a time to call accept on a listening socket..
> >
> > > Which thread binded the socket?
> > >
> > > Alberto
> > >
>
I would rather try and pass the ref to the object and see if
that works, especially if the code below only works on some
OS's. Sorry for leaving out OS, im so used to posting to
Perl-Win32-Users and I am doing this at home on my Linux box.
OS: Linux Redhat 8.0
Perl: 5.8.0
use strict;
use threads;
use threads::shared;
use Net::SMTP::Server;
use Net::SMTP::Server::Client;
my $server;
################
sub ClientWorker
{
my $server = shift;
while (my $conn = $server->accept)
{
HandleClient($conn);
}
}
################
sub HandleClient
{
my ($conn) = shift;
my ($client);
$client = new Net::SMTP::Server::Client($conn) ||
croak("Unable to handle client connection: $!\n");
$client->process;
# save email (eventually)
undef $client;
}
################
sub CreateServer
{
my (%args) = @_;
$$args{S_SERVER} = new Net::SMTP::Server( $args{SMTP_ADDRESS},
$args{SMTP_PORT} );
}
#################
sub CreateWorkers
{
my (%args) = @_;
foreach (1..$args{NUMBER_OF_WORKERS})
{
my $thr = threads->new( \&ClientWorker, $args{SERVER} );
$thr->detach;
}
}
## MAIN ##
CreateServer(
SMTP_ADDRESS => 'localhost',
SMTP_PORT => '3225',
S_SERVER => \$server
);
CreateWorkers(
NUMBER_OF_WORKERS => 10,
SERVER => $server
);
while (1) {}
Regards
Nick
> -----Original Message-----
> From: Alberto Alonso [mailto:[EMAIL PROTECTED]]
> Sent: 22 January 2003 21:12
> To: Joshua Hoblitt
> Cc: Nick Djurovich; [EMAIL PROTECTED]
> Subject: Re: Cannot pass object instance to an existing thread :(
>
>
>
> That's exactly my point. The underlying system seems to make it
> work.
>
> I have not trying to run the code that was posted, that is why I was
> trying to get more info on it.
>
> I think that the thread handling the accepts is the thread that binded
> the socket.
>
> On the other hand all threads may have the correct socket reference,
> which brings up the question as to how the OS signals that the socket
> is already on an accept state, does it wait for it to be released?
>
> Alberto
>
> On Wed, 2003-01-22 at 15:00, Joshua Hoblitt wrote:
> > And what OS are you on? Some platforms (like solaris) only
> allow one process at a time to call accept on a listening socket..
> >
> > > Which thread binded the socket?
> > >
> > > Alberto
> > >
> > > --
> > > Alberto Alonso General Manager Global Gate Systems LLC.
> > > (512) 260-2523 http://www.ggsys.net
> > > Collocation, monitoring, remote backups and consulting solutions
> > >
> > >
> >
> --
> Alberto Alonso General Manager Global Gate Systems LLC.
> (512) 260-2523 http://www.ggsys.net
> Collocation, monitoring, remote backups and consulting solutions
>