Hello, Alex,

>   my $ldt=new IPC::LDT(handle=>$socket, objectMode=>1);
>   ($msg) = $ldt->receive or (print $ldt->{'msg'} && exit
> 1);

this code looks good.


> This code is called from an Event 0.81 io watcher, and
> $socket is $event->w->fd.

Well, this *should* work, but honestly spoken I never tried it this way.
I usually make the IPC::LDT object *with* the socket and pass it as an
argument to the callback, avoiding to construct (and destroy) an
IPC::LDT object with every callback invokation.

Here's a simplified example:

- snip --

 # make socket and LDT object
 my $socket=IO::Socket::INET->new(...);
 my IPC::LDT $clientLdt=new IPC::LDT(handle=>$socket);

 # unbuffer clients income
 $clientSocket->autoflush;

 # register the new connection as event source
 Event->io(
    desc  => "new connection",
    fd  => $socket,
    poll  => 'er',                             # wait for income;
    cb  => sub {serveClient($_[0], $clientLdt)}, # callback (pass event
and LDT objects);
    repeat  => 1,                                       # keep alive
after events;
   );

...

sub serveClient
  {
  # get and check parameters
  my ($event, $ldt)=@_;
  ...

  # we received anything - check it
  my $msg=$ldt->receive;

  # all right?
  unless ($ldt->{rc}==LDT_OK) ...

   ...
  }



- snip --



> Argument "^E^D^B" isn't numeric in subtraction (-) at
> <perlpath>/lib/site_perl/5.6.0/IPC/LDT.pm line 1131.

Hm. Is it possible to send me code to reproduce this behaviour? I wonder
where this string comes from ...

           Jochen



Reply via email to