xref: /PHP-8.2/ext/sockets/tests/socket_bind.phpt (revision 74859783)
1--TEST--
2ext/sockets - socket_bind - basic test
3--CREDITS--
4Florian Anderiasch
5fa@php.net
6--EXTENSIONS--
7sockets
8--SKIPIF--
9<?php
10
11    if (getenv("SKIP_ONLINE_TESTS")) {
12        die("skip test requiring internet connection");
13    }
14?>
15--FILE--
16<?php
17    $s_c     = socket_create(AF_INET, SOCK_STREAM, SOL_TCP);
18    $s_bind  = socket_bind($s_c, '0.0.0.0');
19    var_dump($s_bind);
20
21    // Connect to destination address
22    $s_conn  = socket_connect($s_c, 'www.php.net', 80);
23    var_dump($s_conn);
24
25    // Write
26    $request = 'GET / HTTP/1.1' . "\r\n";
27    $s_write = socket_write($s_c, $request);
28    var_dump($s_write);
29
30    // Close
31    $s_close = socket_close($s_c);
32    var_dump($s_close);
33?>
34--EXPECT--
35bool(true)
36bool(true)
37int(16)
38NULL
39