#!/usr/bin/perl -w #additional header for sockets handling use IO::Socket; #used for the function gethostbyaddr use Net::hostent; use File::FDpasser; my $LS=endp_create("/tmp/handoff") || die "endp_create: $!\n"; chmod 0777, "/tmp/handoff"; my $fh; while ($fh = serv_accept_fh($LS)) { printf STDERR "accepted a connection...\n"; my $client = recv_fh($fh); printf STDERR "received a filehandle...\n"; my $request; { local $/; $request = <$fh>; close $fh; printf STDERR "request = $request\n"; } bless $client, 'IO::Socket::INET'; # $client->autoflush(1); #welcome # print STDERR `ls -l /proc/$$/fd`; print $client "HTTP/1.1 200 OK\r\n"; print $client "Content-Type: text/plain;\r\n"; print $client "Connection: close\r\n"; print $client "Pragma: no-cache\r\n"; print $client "Cache-control: no-cache\r\n"; print $client "\r\n"; print $client "Foo!\r\n"; $client->flush(); sleep 2; print $client "Bar!\r\n"; $client->flush(); sleep 2; print $client "Baz!\r\n"; $client->flush(); close $client; } #the socket $client is closed #to close the socket $server: ctrl+c