I am trying to understand/create a chat server/client for a project. I
noticed that there is a chat server on POE Cookbook and I have been using it
as a guide as I try to understand how POE works. The problem that I'm having
is how to get the client to work. Currently I have used this code, which is
an edited code from POE Cookbook to connect to the server:
#!/usr/bin/perl -w

use strict;
use POE;
use POE::Component::Client::TCP;

my $host   = "localhost";    # The host to test.
my $port   = 11211;

POE::Component::Client::TCP->new
  ( RemoteAddress => $host,
    RemotePort => $port,
    Connected  => sub {
        print "connected to $host:$port ...\n";
    },
    ConnectError => sub {
        print "could not connect to $host:$port ...\n";
    },
    ServerInput => sub {

        #when the server answer the question
        my ( $kernel, $heap, $input ) = @_[ KERNEL, HEAP, ARG0 ];
        #print to screen the result
        print $$input. "\n";
    },
  );
$poe_kernel->run();
exit 0;

What I want to do is try to type something into the console and have it
repeated to me. This is just a test so in the real system this would not be
the case. I cant figure how to get what I type in the console to the server.
I tried using an InlineState but I'm not sure how it works. If anyone could
help me out that would be great.

-- 
Jamie Ryan Lahowetz
University of Nebraska - Lincoln
Graduate Student - Geosciences
249 Hardin Hall, Section 21
402.304.0766
[EMAIL PROTECTED]

Reply via email to