Close the server socket in php bind stager

This was previously left dangling, which leaves the port open, but
doesn't do anything with subsequent connections.
bug/bundler_fix
James Lee 2014-07-03 16:52:09 -05:00
parent 9246f7a0ce
commit 41cd5527c8
No known key found for this signature in database
GPG Key ID: 2D6094C7CEA0A321
1 changed files with 5 additions and 2 deletions

View File

@ -9,17 +9,20 @@ if (is_callable('stream_socket_server')) {
$srvsock = stream_socket_server("tcp://{$ipaddr}:{$port}");
if (!$srvsock) { die(); }
$s = stream_socket_accept($srvsock, -1);
fclose($srvsock);
$s_type = 'stream';
} elseif (is_callable('socket_create_listen')) {
$srvsock = socket_create_listen(AF_INET, SOCK_STREAM, SOL_TCP);
if (!$res) { die(); }
$s = socket_accept($srvsock);
socket_close($srvsock);
$s_type = 'socket';
} elseif (is_callable('socket_create')) {
$srvsock = socket_create(AF_INET, SOCK_STREAM, SOL_TCP);
$res = socket_bind($srvsock, $ipaddr, $port);
if (!$res) { die(); }
$s = socket_accept($srvsock);
socket_close($srvsock);
$s_type = 'socket';
} else {
die();