in reply to Re: Socket hangs
in thread Socket hangs
Here is the code after sugested changes:# ./client.pl Command> uname Linux
It`s still freezing, what is wrong? Thank you!sub listen() { $local = IO::Socket::INET->new(Listen=>1, Proto=>'tcp', LocalAddr=>'eth0', LocalPort=>5000, ReuseAddr=>1,) or die "$!"; $local->autoflush(1); $sel = new IO::Select($local); while(@ready = $sel->can_read) { print "Command> "; foreach $fh (@ready) { if($fh == $local) { # Create a new socket $new = $local->accept; $sel->add($new); $comm = <STDIN>; print $new $comm; sub closeback() {exit(0)} while(sysread($new,$buffer,1024)) { print $buffer } } } } }
|
|---|