[Spread-users] select on mailbox perl

Theo Schlossnagle jesus at omniti.com
Mon Aug 15 07:29:27 EDT 2005


On Aug 15, 2005, at 6:13 AM, Ilya Zaytsev wrote:

> I have a perfectly working perl script under winxp and now I'm trying
> to rewrite it to call select (and IO::Select) on mail box handle but
> no success. select call returns -1 and IO::Select->can_read doesn't
> read events. I have seen the XS source code but nothing comes to my
> head. The same technique woks fine for C code.
>
> Does anybody experienced the same problem?

Without a code segment, it's hard to say.  The connect command in  
Spread returns a list of two things:
  ( $mbox, $private_group )

The $mbox is an IV in perlguts terms, which means it is a scalar  
value representation of the file descriptor.  This is becuase Spread  
returns a mailbox that _happens_ to be a filedescriptor.  The API  
allows Spread to be more creative and return some sort of psuedo  
handle, so watch out for future incompatibility.

Something like:

use IO::Select;
use IO::Handle;
my $mbox, $ioh;
... do you Spread connect stuff and jam the mailbox in $mbox;

my $ioh = IO::Handle->fdopen($mbox, "rw");

You should be able to IO::Select on $ioh as a normal "IO" handle  
now.  It works in UNIX :-)  Windows file descriptors aren't  
contiguous and it emulates select() under the hood in a fairly  
expensive way.  I _assume_ that Perl uses the emulation for  
IO::Select or there would be ample documentation stating that it  
didn't work.  You are changing the $mbox into an actual IO object,  
right?

Cheers ;-)



// Theo Schlossnagle
// Principal Engineer -- http://www.omniti.com/~jesus/
// OmniTI Computer Consulting, Inc. -- http://www.omniti.com/
// Ecelerity: fastest MTA on Earth


-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.spread.org/pipermail/spread-users/attachments/20050815/6e4eb629/attachment.html 


More information about the Spread-users mailing list