关于perl网络编程的问题
我在linux下用perl写一个服务器端的代码,具体如下:
use IO::Socket
$sock = new IO::Socket::INET(LocalHost => '127.0.0.1 ',
LocalPort => 1200,
Proto => 'tcp ',
Listen => 5,
Reuse => 1);
die "Socket couldn 't be created.Reason: $! "
while ($new_sock = $sock -> accept()){
while (defined($buf = <$new_sock> )){
printf $buf;
}
}
close ($sock)
我在编译的时候,提示Socket couldn 't be created.Reason: 非法 seek 操作,
不知道那位高手能帮小弟解答一下,为什么socket不能建阿
[解决办法]
纠正点小问题:
use IO::Socket;
$sock = new IO::Socket::INET(LocalHost => '127.0.0.1 ',
LocalPort => 1200,
Proto => 'tcp ',
Listen => 5,
Reuse => 1)
or die "Socket couldn 't be created. Reason: $! ";
while ( $new_sock = $sock-> accept() ) {
while ( defined($buf = <$new_sock> ) ) {
print $buf;
}
}
close ($sock);
然后我这边可以正常运行,没出现什么错误。