in reply to Re: POE Multitasking Client/Server
in thread POE Multitasking Client/Server

I am using winxp and perl 5.8.8. Got an error from the cookbook samples provided. Prototype mismatch: sub POE::Kernel::F_GETFL: none vs () at POE/Resource/FileHandles.pm line 24. by using version from CPAN of POE1.0004 I knew that F_GETFL and F_SETFL will not work in windows. so i reverted back to older version of POE '0.9999'; The error was not seen but I can't see any Tk window appearing in my screen. Am i using the right one?? or any modification has to be done with this.

Replies are listed 'Best First'.
Re^3: POE Multitasking Client/Server
by cmv (Chaplain) on Oct 23, 2008 at 19:38 UTC
    muthuma-

    I don't think the F_GETFL or F_SETFL warnings are part of your current problem. See Re^5: sending data over TCP channel using POE::Component::Server::TCP on this. I've tested the following example under windows and unix (various). It still works even with the warning messages under windows.

    I've been asking for so much help on POE stuff lately, here is what I can give back. Hope it helps.

    -Craig

    use strict; use warnings; use Tk; # This MUST come before use POE... use POE; use POE::Component::Client::TCP; use Data::Dumper; # This connects to the ssh port on the local machine (modify as requir +ed)... my $host = 'localhost'; my $port = '22'; my $textw; # Global for text widget _processData(); _displayData(); print STDERR "STARTING to process data...\n"; POE::Kernel->run; exit; sub _processData{ POE::Component::Client::TCP->new( RemoteAddress => $host, RemotePort => $port, Filter => "POE::Filter::Line", Alias => 'myClient', Connected => sub { $textw->insert(end=>"connected to $host:$port ...\n"); $textw->update; }, ConnectError => sub { $textw->insert(end=>"no connection to $host:$port. Reconne +cting in 5...\n"); $textw->update; $_[KERNEL]->delay( reconnect =>5 ); }, ServerInput => sub { my $input = $_[ARG0]; $_[KERNEL]->post(Display=>data=>$input); }, ); } sub _displayData{ POE::Session->create( inline_states => { _start => sub { my $kern = $_[KERNEL]; $kern->alias_set("Display"); my $top = $poe_main_window; my $sess=$kern->alias_resolve('myClient') || die("Can't resolve myClient"); $textw = $top->Scrolled('Text', -scrollbars=>'osow', -wrap=>'none')-> pack(-fill=>'both',-side=>'left', -expand=>1); }, data=>sub{ $textw->insert(end=>$_[ARG0] . "\n"); $textw->update; }, }); }