On Thu, Feb 19, 2004 at 08:00:37AM -0600, Jay Strauss wrote:
> > > If I'm using POE::Component::Client::TCP is there a way I can
> > > manually read the socket, as opposed to having each message fire
> > > the ServerInput method?  It might seem counter POE, but I'd like
> > > to get the ConnectError, Disconnected, and Filter from
> > > Client::TCP, but I want to read the message in at my own pace.
> >
> > No.  Disconnect happens as a result of sysread() returning error zero.
> > Client::TCP can't announce a disconnection unless it's also reading the
> > socket.
> >
> > Have you seen http://poe.perl.org/?Evolution_of_a_poe_server ?  It's
> > server side, but it shows a few different ways to build and work with
> > sockets.  Maybe Wheel::SocketFactory and Wheel::ReadWrite (or perhaps
> > just select_read) will suit your problem better.
> 
> If I want to read the socket manually, Wheel::ReadWrite (I think) is going
> to present the same problem as Component::TCP::Client, that is, every time
> some data comes down the pipe it's going to invoke an event.

You can combine techniques from the tutorial.  SocketFactory can make
the non-blocking connection for you (or you can use IO::Socket::INET if
you don't mind it blocking).  Then you can use select_read() on the
resulting socket to be notified when to read from it.

> My situation is the server sends variable length records down the pipe, I
> have to pick up the record type (first) to figure out how many more fields
> to read.  Furthermore within the records are embedded records (with a field
> telling me how many records are within).  And lastly, there is a record
> version #, which tells me the format (old, new) of the record (i.e. as more
> functionality is added to the server, more fields are added to the record
> sent down the pipe), I need to talk to various versions of the server.
> 
> If I get an event for each field, buffer it, then have this hairy logic to
> figure out if I've got enough data.  I'll have to do this over and over for
> each field.
> 
> I think I'm going to have to roll my own.

You work with the wackiest protocols.  Can you fit all this magic into a
filter instead of writing an entire server from scratch?

-- 
Rocco Caputo - [EMAIL PROTECTED] - http://poe.perl.org/

Reply via email to