$app->handle($request)); $address = "127.0.0.1:8000"; $socket = new SocketServer($address); $http->listen($socket); $http->on('error', function ($error) use ($socket) { fprintf(STDERR, $error->getMessage() . "\n"); fprintf(STDERR, "Closing socket connection.\n"); $socket->close(); }); $http->on('exit', function () use ($socket) { fprintf(STDOUT, "Closing socket connection.\n"); $socket->close(); }); fprintf(STDOUT, "Server running on %s\n", $address); } catch (\Exception $e) { fprintf(STDERR, "Error caught bootstrapping the application\n"); fprintf(STDERR, $e->getMessage() . "\n"); return -1; }