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