Ok, the following is taken from a simple perl irc server that I was using as a basis for writing something else. Is this what you were talking about? This is very simple, and just prints everything that it gets out. It's simpler than it looks, I promise. Just look it over.

#!/usr/bin/perl

use strict;

use IO::Socket;
use IO::Select;
use POSIX;

my $server;
my $select;
my %clients;

$SIG{INT} = sub { foreach(values(%clients)) { close; } close $server; exit; };

sub start_listening {
  $server = IO::Socket::INET->new(Proto=>"tcp", LocalPort=>"8900", Listen=>1) or
 die "Can't open socket\n";
  $select = IO::Select->new($server);
}

sub main_loop {
  while(1) {
    foreach my $client ($select->can_read(1)) {
      if($client == $server) { #connection waiting to be handled...
        $client = $server->accept();
        $select->add($client);
        &setnonblocking($client);
        $clients{$client} = $client;
      } elsif(defined($clients{$client})) {
        my $pending;
        my $data;
        
        $pending = $client->recv($data,POSIX::BUFSIZ,0);
        
        if($pending) {
          print $data;
        }
      }
    }
  }
}

sub setnonblocking {
  my $sock = shift;
  # Get the current state of the socket..
  my $flags = fcntl($sock, F_GETFL, 0) or
    die "Can't get the flags on socket: $!\n";
  # ..and then add O_NONBLOCK (nonblocking-ness) on to it.
  fcntl($sock, F_SETFL, $flags | O_NONBLOCK) or
    die "Can't set socket non-blocking: $!\n";
}   

start_listening();
main_loop();

In reply to RE: Using socket descriptor with IO::Select by ender
in thread Using socket descriptor with IO::Select by BrianCM

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.