Hi, Excuse me for spamming a long mail. Stumbled upon POE and want to use it for my latest project. The issue with my application seems to be related to sending events from other sessions to TCP Client Component.
This application needs to tail a log file and send data to a remote host. Since POE cookbook already has solution patterns for TCP based communication and tailing log files I am trying to re-use as much as I can. I am creating 2 sessions. First one, alias Gatekeeper, is a standard POE::Component::Client::TCP to connect to a remote host to send data to. The other session is a basic POE::Session which listens for some log files. So as soon as I get an event callback about a message, I post data using the first session. The program works fine if the second session that reads from the log file with a “Seek” offset set to 0 (basically processing the log file from start). However, when I specify any seek offset, the program crashes when I call put() to send data to the remote host. This is how the pseudo code looks like: my $seekPosition = <STDIN>; chomp($seekPosition); ## SESSION WRAPPER TO TALK TO THE SERVER my $server = POE::Component::Client::TCP->new( Alias => "GateKeeper", RemoteAddress => $host, RemotePort => $port, Filter => "POE::Filter::Stream", Connected => sub { print “\ngood to go”; } , ); ### SESSION TO TAIL LOG FILE POE::Session->create( inline_states => { _start => \&begin_watchers, # Handle records from each log differently. msg_record => \&msg_got_record, } ); sub begin_watchers { my $heap = $_[HEAP]; my $watcher = POE::Wheel::FollowTail->new( Filename => $log_file, InputEvent => "msg_record", Seek => $seekPosition, # when this is 0, program works file ); $heap->{watchers} = $watcher; } sub msg_record { my $log_record = $_[ARG0]; $server->put($log_record); # when seek is not 0, the program crashes here saying $server is undefined. } $poe_kerner->run(); Is there something obviously wrong here when the user tries to give an offset other than 0 or the way I am trying to send data to the server. Any advice would be a great help. Thanks D