At 15:30 -0500 12/19/03, Al Tobey wrote:
> Why are you doing:

threads->self->yield;


in make_client? Does the problem occur when you remove this, or replace it by:

threads->yield;

Mistake, but removing it entirely does not change the result of the test. It's irrelevant and probably stupid - I just put it there to make sure that the server could get ready in time.

Have you tried replacing it with a "sleep 5" or something like that? That would at least rule out that.



Alternately, could you try this approach:


=====================================================
#!/usr/local/bin/perl -w
use strict;
use threads;

my $server = threads->create( \&make_server );
sleep 1;
my $client = threads->create( \&make_client );

$client->join();
$server->join();

exit 0;

sub make_server {
    require Net::SNPP; Net::SNPP->import;
    require Net::SNPP::Server; Net::SNPP::Server->import;
    my $server = Net::SNPP::Server->new(
        Port => 20001,
        BindTo => 'localhost'
    );
    my $client = $server->client();
    $server->handle_client( $client );
}

sub make_client {
    require Net::SNPP; Net::SNPP->import;
    threads->self->yield;
    my $client = Net::SNPP->new( 'localhost', Port=>20001 );
    $client->send( Pager=>5555555555, Message=>"TEST" );
    $client->quit;
}
=====================================================

This moves the loading of the Net::SNPP modules to run time inside the thread. If this fixes the problem, it would mean that Net::SNPP isn't capable of running in different threads.


Liz

Reply via email to