sub uds_script()

in t/modules/proxy.t [168:189]


sub uds_script
{
    use Socket;
    use strict;

    my $socket_path = shift;
    my $sock_addr = sockaddr_un($socket_path);
    socket(my $server, PF_UNIX, SOCK_STREAM, 0) || die "socket: $!";
    bind($server, $sock_addr) || die "bind: $!";
    listen($server,1024) || die "listen: $!";
    open(MARKER, '>', $socket_path.'.marker') or die "Unable to open file $socket_path.marker : $!";
    close(MARKER);
    if (accept(my $new_sock, $server)) {
        my $data = <$new_sock>;
        print $new_sock "HTTP/1.0 200 OK\r\n";
        print $new_sock "Content-Type: text/plain\r\n\r\n";
        print $new_sock "hello world\n";
        close $new_sock;
    }
    unlink($socket_path);
    unlink($socket_path.'.marker');
}