[[email protected]: question on IPC::LDT implementation with Event.pm]

[email protected] (Joshua N Pritikin) Wed, 18 Aug 2004 23:00:06 +0530
Newsgroups perl.loop
Message-ID <[email protected]>
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";
	},
);
signature.asc (application/pgp-signature, 189 B)
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.2.4 (GNU/Linux)

iD8DBQFBI5IeqcqnlKSmC70RApsUAKCHGKtrdpEenn8H7qiERhSModyvogCgqnGb
9rILGUmqX2Dy1+geO7uyzCk=
=fNqD
-----END PGP SIGNATURE-----