Well, i tryed to use shutdown() but i`ve got same behavior but in other hand i could make it work but still have some small problems, take a look:
# ./client.pl
Connected from: 127.0.0.1:33703
Command> >uname
Linux
Command> id nobody
uid=99(nobody) gid=99(nogroup) groups=99(nogroup),98(nobody)
Command>
That is ok, but in some commands (i dont know why) i can execute them sucessfully and them i`ve freeze again, look:
Command> touch test
And look what happens if i use ";" followed by some other command:
Command> touch test ; ls
client.pl
client.pl~
salvo.pl
server.pl
server.pl~
test
Command>
Here is the code:
sub listen() {
$local = IO::Socket::INET->new(Listen=>1,
Proto=>'tcp',
LocalAddr=>'eth0'
LocalPort=>5000,
ReuseAddr=>1,) or die "$!";
$local->autoflush(1);
$addr = $local->accept();
$remotehost = $addr->peerhost ;
$remoteport = $addr->peerport ;
print "Connected from: $remotehost:$remoteport\n";
print "Command> ";
while($comm = <STDIN>) {
print $addr $comm;
sub closeback() {exit(0)}
while(sysread($addr,$buffer,1024)) {
print $buffer;
last;
}
print "Command> ";
}
}
Any tip? thanks. |