0
我试图用perl创建一个tcp套接字服务器。我成功地创建了一个侦听特定端口的服务器。但在服务一个客户端请求后,Socket服务器正在关闭。服务器不在侦听多个客户端请求。服务客户端在perl后套接字连接关闭
while (accept(Client, Server)) {
# do something with new Client connection
if ($kidpid = fork) {
close Client; # parent closes unused handle
#next REQUEST;
next REQUEST if $!{EINTR};
}
print "$kidpid\n";
defined($kidpid) or die "cannot fork: $!" ;
close Server; # child closes unused handle
select(Client);
$| = 1; ]
select (STDOUT);
# per-connection child code does I/O with Client handle
$input = <Client>;
print Client "output11\n"; # or STDOUT, same thing
open(STDIN, "<<&Client") or die "can't dup client: $!";
open(STDOUT, ">&Client") or die "can't dup client: $!";
open(STDERR, ">&Client") or die "can't dup client: $!";
print "finished\n";
close Client;
exit;
}
我无法在上面的代码中找到问题。有人可以帮助我吗?
您显示的代码是一个语法错误(至少是杂散的,不匹配的''''''''''''''''',可能还有一个运行时错误(缺少REQUEST标签))。你可以把它变成[显示问题行为的最小代码](http://sscce.org/)? – pilcrow