mirror of
https://github.com/php/php-src.git
synced 2026-04-29 19:23:22 +02:00
Scan through a range of ports in case 31338 is busy
ext/standard/tests/network/ud4loop.phpt hardcodes port 31338. If that fails to bind, try a few more (up to 31499) before giving up.
This commit is contained in:
@@ -3,13 +3,17 @@ Streams Based IPv4 UDP Loopback test
|
||||
--FILE--
|
||||
<?php
|
||||
/* Setup socket server */
|
||||
$server = stream_socket_server('udp://127.0.0.1:31338', $errno, $errstr, STREAM_SERVER_BIND);
|
||||
for ($port = 31338; $port < 31500; ++$port) {
|
||||
$uri = "udp://127.0.0.1:$port";
|
||||
$server = @stream_socket_server($uri, $errno, $errstr, STREAM_SERVER_BIND);
|
||||
if ($server) break;
|
||||
}
|
||||
if (!$server) {
|
||||
die('Unable to create AF_INET socket [server]');
|
||||
die('Unable to create AF_INET socket [server]: ' . $errstr);
|
||||
}
|
||||
|
||||
/* Connect to it */
|
||||
$client = stream_socket_client('udp://127.0.0.1:31338');
|
||||
$client = stream_socket_client($uri);
|
||||
if (!$client) {
|
||||
die('Unable to create AF_INET socket [client]');
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user