Can anyone offer a clue?

----- Forwarded message from [EMAIL PROTECTED] -----

From: [EMAIL PROTECTED]
To: [EMAIL PROTECTED]
Subject: question on IPC::LDT implementation with Event.pm


Hi Joshua,

    Would like a little help from you. In your Event tutorial, you mention on
using non-blocking socket using IPC::LDT perl module. I try to use but
encounter errors on the receive. here's my snipprt code. I hope u can point out
my errors.

# make socket
my $socket=IO::Socket::INET->new(Listen=>5, LocalPort=>8001, Reuse=>1);
die "[Fatal] Cannot build initial socket.\n" unless $socket;

DEBUG && print ("start smpp service\n");

# install an initial watcher
Event->io(
        fd => $socket,
        cb => sub {
# make "channel" number
                my $channel=++$channels;

# accept client
                my $client=$socket->accept;
                warn "[Error] Cannot connect to new client.\n" and return unless 
$client;
                $client->autoflush;

# install a communicator
                Event->io(
                        fd => $client,
                        cb => sub {
# report
                warn "[Server] Talking on channel $channel.\n";
                my $handle = $_[0]->w->fd;
                my $ldt = new IPC::LDT(handle=>$handle,traceMode=>1);
                my $msg = $ldt->receive() or die $ldt->{'msg'};
                print "Message $msg\n";
                if ( $msg =~ /quit\r$/i/){
                    $_[0]->w->cancel;
                }
                                }
                        },
                );

# welcome
                $client->print("Welcome, this is Channel $channel.\n");

# report
                warn "[Server] Opened new channel $channel.\n";
        },
);

Attachment: signature.asc
Description: Digital signature

Reply via email to