in reply to Sending and recieving data

I can see you've got some code going, but you're going to need to make a structured plan. Start off by opening any outgoing sockets that you need, then wait for a connection on a local port. When you get the connection, you'll need to accept it, then do non-blocking reads while checking for new connections. It's fairly complicated.

If you don't want to get that complicated, try POE.

____________________
Jeremy
I didn't believe in evil until I dated it.

Replies are listed 'Best First'.
Re: Re: Sending and recieving data
by jasonk (Parson) on Feb 24, 2003 at 04:20 UTC

    Just my opinion, but POE is far more complicated.

      While I would agree that if you look at POE from a low level, there is quite a learning curve to surmount - However, for use in a real-world, practical sense, POE isn't nearly as difficult as it first seems. The documentation at http://poe.perl.org is a bit patchy in places, but it is improving.

      For example, from the POE cookbook documentation, the following code acts as a non-blocking echo server, much like what the venerable Anonymous Monk seeks and is relatively straight-forward to follow:

      #!/usr/bin/perl use POE; use POE::Component::Server::TCP; use strict; POE::Component::Server::TCP->new ( 'Alias' => "echo", 'Port' => 2000, 'ClientInput' => sub { my ( $session, $heap, $input ) = @_[ SESSION, HEAP, ARG0 ]; $heap->{client}->put($input); } ); $poe_kernel->run(); exit 0;

       

      perl -le 'print+unpack("N",pack("B32","00000000000000000000001000110100"))'