Good day Monks,

I have recently downloaded POE: POE Cookbook/TCP Port Redirection With Components. I changed the outgoing port of the client side process to be port 80 on another IP. Regardless when I try and open port 1110 my poe program gives an error as follows:
Can't locate object method "put" via package "POE::Wheel::SocketFactory" at portforward.pl line 76.

Herewith the code:
#!/usr/bin/perl use warnings; use strict; use POE qw(Component::Server::TCP Component::Client::TCP); # Spawn the forwarder server on port 1110. When new connections # arrive, spawn clients to connect them to their destination. POE::Component::Server::TCP->new( Port => 1110, ClientConnected => sub { my ( $heap, $session ) = @_[ HEAP, SESSION ]; #logevent( 'server got connection', $session ); spawn_client_side(); }, ClientInput => sub { my ( $kernel, $session, $heap, $input ) = @_[ KERNEL, SESSION, + HEAP, ARG0 ]; #logevent( 'server got input', $session, $input ); $kernel->post( $heap->{client_id} => send_stuff => $input ); }, ClientDisconnected => sub { my ( $kernel, $session, $heap ) = @_[ KERNEL, SESSION, HEAP ]; #logevent( 'server got disconnect', $session ); $kernel->post( $heap->{client_id} => "shutdown" ); }, InlineStates => { send_stuff => sub { my ( $heap, $stuff ) = @_[ HEAP, ARG0 ]; #logevent( "sending to server", $_[SESSION] ); $heap->{client}->put($stuff); }, _child => sub { my ( $heap, $child_op, $child ) = @_[ HEAP, ARG0, ARG1 ]; if ( $child_op eq "create" ) { $heap->{client_id} = $child->ID; } }, }, ); sub spawn_client_side { POE::Component::Client::TCP->new( RemoteAddress => '192.168.0.200', RemotePort => 81, Started => sub { $_[HEAP]->{server_id} = $_[SENDER]->ID; }, Connected => sub { my ( $heap, $session ) = @_[ HEAP, SESSION ]; #logevent( 'client connected', $session ); }, ServerInput => sub { my ( $kernel, $heap, $session, $input ) = @_[ KERNEL, HEAP +, SESSION, ARG0 ]; #logevent( 'client got input', $session, $input ); $kernel->post( $heap->{server_id} => send_stuff => $input +); }, Disconnected => sub { my ( $kernel, $heap, $session ) = @_[ KERNEL, HEAP, SESSIO +N ]; #logevent( 'client disconnected', $session ); $kernel->post( $heap->{server_id} => 'shutdown' ); }, InlineStates => { send_stuff => sub { my ( $heap, $stuff ) = @_[ HEAP, ARG0 ]; #logevent( "sending to client", $_[SESSION] ); $heap->{server}->put($stuff); }, }, ); } sub logevent { my ( $state, $session, $arg ) = @_; my $id = $session->ID(); print "session $id $state "; print ": $arg" if ( defined $arg ); print "\n"; } warn 'running'; $poe_kernel->run(); exit 0;

In reply to Problem with POE and Port Forwarding by avo

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.