Don't use an asynchronous client if you don't need one. The cookbook includes examples using POE::Filter::Reference by itself.
-- Rocco Caputo <rcap...@pobox.com> On Jan 31, 2013, at 09:41, Antti Linno wrote: > Hm, as my needs for application server are very simple, I feel that POE TCP > client is too heavy, compared to IO::Socket for example. > > Slim client=> > > use IO::Socket; > use JSON qw( encode_json ); > > my $sock = new IO::Socket::INET ( > PeerAddr => 'localhost', > PeerPort => '11211', > Proto => 'tcp' > ); > print $sock ( encode_json( { event => "position", phone => "12345" } ) . > '[EOM]' ); > close $sock; > exit; > > In server I parse messages with=> > > POE::Component::Server::TCP->new( > Alias => "emt_server", > Address => "localhost", > Port => 11211, > ClientFilter => [ "POE::Filter::Line", Literal => "[EOM]" ], > > ClientConnected => sub { > say "Client connected"; > }, > # Handle client requests here. > ClientInput => sub { > my ( $heap, $params_json ) = @_[ HEAP, ARG0 ]; > print $params_json; > Wrapper::emt_event( decode_json $params_json ); > }, > > This works. But I somehow feel that this is not elegant solution. How do I > use POE::Filter::Reference instead of Line? Tried to freeze and send, but > the server did not enter ClientInput event. Is there a slim and elegant > solution? :) Or should I use cookbook client and just kill client after > every request with $kernel->yield("shutdown")? Cookbook client works fine. > > If I use ClientFilter => [ "POE::Filter::Reference", "YAML" ], I cannot > trigger ClientConnected subroutine with IO::Socket :) Tried to use > standalone Filter::Reference->put and send it over socket, but still no > luck. > > Thank you all. > > > On Wed, Jan 30, 2013 at 7:29 PM, Antti Linno <antti.li...@gmail.com> wrote: > >> Thank you. You saved me from fourth standalone daemon :D >> >> >> On Wed, Jan 30, 2013 at 5:09 PM, Rocco Caputo <rcap...@pobox.com> wrote: >> >>> On Jan 30, 2013, at 09:49, Antti Linno wrote: >>>> >>>> Or I need advice, how to merge several sungo's( >>>> http://poe.perl.org/?POE_Cookbook/TCP_Servers) daemons into one >>> package, if >>>> someone would be so kind. Adding UDP should be fairly similar then. >>> >>>> Any hints, second opinion(maybe not to merge TCP and UDP), or code >>> examples >>>> are welcome :) >>> >>> >>> I've attached a working version of your sample code. It starts two TCP >>> servers and a UDP service, and lets them all run at once in the same >>> process. >>> >>> -- >>> Rocco Caputo <rcap...@pobox.com> >>> >>> >>> >>> >>> >>> >>