> On Wed, Jan 03, 2001 at 01:52:43PM -0800, Rob Bloodgood wrote:
> >
> > That being the case, I started with Socketfactory.perl as my
> starting point,
> > to get me running w/ a tcp server out of the gate.
> > (is there a "more efficient", "more idiomatic" way to do this?
> comments?)
> I think POE::Component::Server::TCP is what you are looking for. But it's
> probably not much shorter.

oh, likely, except Server::TCP doesn't support binding to a specific
interface (yet).

> > 1) At first, I couldn't keep my DB session alive...
> >    however, I ended up solving that by creating an alias to it
> so I could
> > access it from another state:
> >     #  from StreamServerSession::gotline()
> >     #  print the results of DBFetch::fetch out to the socket
> >     $kernel->call( db => fetch => $line, $heap->{wheel} ) or
> die "couldn't
> > execute db::fetch: $!";
> >
> >     But that seems kinda crufty... especially the passing of
> > the wheel as a parameter in another session.
>
> well i don't really know what your doing there but i haven't
> needed to pass
> wheel references yet. passing the line itself should be enough.

Well, no... I want to post a "reply" back to the client via the wheel.
The fetch state does the equivalent of (and this is pseudocode):

my ($line, $wheel) = @_[ARG0, ARG1];
my @criteria = split ' ', $line;

foreach (@possibilities) {
    $answer = $_, last if $meets_all_@criteria
}

$response = $answer

###  THIS IS THE REASON FOR MY DBFETCH SESSION
if ( crossed_a_watermark() ) {
        $kernel->yield('update_values');
}

$wheel->put($answer);

return 1; # found out this one by accident, else $kernel->call fails

============

While I'm at it, I've solved my #3 from my previous post...

in my _stop sub, I said:

sub _stop {
 my ($object, $heap) = $_[OBJECT, HEAP];

 print "$object is stopped.\n";
}

see it?  $_[] instead of @_[].  If I read the parsing correctly, I was
getting my HEAP in $object, and $heap was undef. <sigh>

perl -wc myproggy is DEFINITELY your friend :-)

L8r,
Rob

Reply via email to