1<?php
2
3$socket = stream_socket_server("tcp://127.0.0.1:0", $errno, $errstr);
4if (!$socket) {
5    echo "Can't start server: $errstr ($errno)\n";
6    exit(1);
7}
8
9$filename = $argv[1];
10$payload = file_get_contents($filename);
11if ($payload === false) {
12    echo "Can't read $filename\n";
13    exit(1);
14}
15
16fputs(STDERR, "FB payload server listening on " . stream_socket_get_name($socket, false) . "\n");
17
18while ($conn = stream_socket_accept($socket)) {
19    fwrite($conn, $payload);
20}
21