Skip to content

Commit f15a49f

Browse files
Add IPv6 support for Swoole (#728)
* Add IPv6 support Use the listen host address to determine whether Swoole should listen on an IPv4 or IPv6 socket. * Update createSwooleServer.php --------- Co-authored-by: Taylor Otwell <[email protected]>
1 parent 1ae420e commit f15a49f

File tree

1 file changed

+7
-3
lines changed

1 file changed

+7
-3
lines changed

bin/createSwooleServer.php

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,13 +3,17 @@
33
$config = $serverState['octaneConfig'];
44

55
try {
6+
$host = $serverState['host'] ?? '127.0.0.1';
7+
8+
$sock = filter_var($host, FILTER_VALIDATE_IP, FILTER_FLAG_IPV4) ? SWOOLE_SOCK_TCP : SWOOLE_SOCK_TCP6;
9+
610
$server = new Swoole\Http\Server(
7-
$serverState['host'] ?? '127.0.0.1',
11+
$host,
812
$serverState['port'] ?? 8080,
913
$serverState['mode'] ?? SWOOLE_PROCESS,
1014
($config['swoole']['ssl'] ?? false)
11-
? SWOOLE_SOCK_TCP | SWOOLE_SSL
12-
: SWOOLE_SOCK_TCP,
15+
? $sock | SWOOLE_SSL
16+
: $sock,
1317
);
1418
} catch (Throwable $e) {
1519
Laravel\Octane\Stream::shutdown($e);

0 commit comments

Comments
 (0)