perlを使用してtcpソケットサーバーを作成しようとしていました。特定のポートをリッスンするサーバーを作成することに成功しました。しかし、1 つのクライアント リクエストを処理した後、ソケット サーバーが閉じられます。サーバーは複数のクライアント要求をリッスンしていません。
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;
}
上記のコードで問題を見つけることができません。誰かがこれについて私を助けてくれませんか?