Here is ths fix for the script I made... I was having problems because I
always was printing $userinput, and not checking weather it has any data
or not. 
#!/usr/bin/perl -w
use IO::Socket;
use IO::Select;
use strict;

my $port = 12;
my $debugging = 1;
my $serversock = IO::Socket::INET->new(LocalPort => $port,
Type => SOCK_STREAM,
Reuse => 1,
Listen => SOMAXCONN)
or die "Couldn't create server on $port: $!";
my $selectobj = IO::Select->new; 
$selectobj->add($serversock); 
my $userinput = '';

while(1) { 
my @ready = $selectobj->can_read(15);
foreach my $handle (@ready) { 
if($handle == $serversock) {
my $client = $serversock->accept;
$selectobj->add($client); 
if($debugging) { 
my $hersockaddr = getpeername($client);
my ($port, $iaddr) = sockaddr_in($hersockaddr);
my $herhostname = gethostbyaddr($iaddr, AF_INET);
my $herstraddr = inet_ntoa($iaddr); 
print "Remote client connection accepted from: $herhostname
$herstraddr:$port\n"; 
} 
} else {
$userinput = <$handle>; 
} 
my @ready2 = $selectobj->can_write(15);
unless($userinput eq '') {
foreach (@ready2){
print $_ "$userinput\n";
} 
} 
} 
}
_______________________________________________
ActivePerl mailing list
[EMAIL PROTECTED]
To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs

Reply via email to