1--TEST--
2bool socket_shutdown ( resource $socket [, int $how = 2 ] ) ;
3--CREDITS--
4marcosptf - <marcosptf@yahoo.com.br> - #phparty7 - @phpsp - novatec/2015 - sao paulo - br
5--EXTENSIONS--
6sockets
7--SKIPIF--
8<?php
9
10if(substr(PHP_OS, 0, 3) != 'WIN' ) {
11    die('skip windows only test');
12}
13if (getenv("SKIP_SLOW_TESTS")) {
14    die("skip slow test");
15}
16if (getenv("SKIP_ONLINE_TESTS")) {
17    die("skip online test");
18}
19
20?>
21--FILE--
22<?php
23$host = "yahoo.com";
24$port = 80;
25
26$socket = socket_create(AF_INET, SOCK_STREAM, SOL_TCP);
27$socketConn = socket_connect($socket, $host, $port);
28var_dump(socket_shutdown($socket,0));
29socket_close($socket);
30
31$socket = socket_create(AF_INET, SOCK_STREAM, SOL_TCP);
32$socketConn = socket_connect($socket, $host, $port);
33var_dump(socket_shutdown($socket,1));
34socket_close($socket);
35
36$socket = socket_create(AF_INET, SOCK_STREAM, SOL_TCP);
37$socketConn = socket_connect($socket, $host, $port);
38var_dump(socket_shutdown($socket,2));
39socket_close($socket);
40
41$socket = socket_create(AF_INET, SOCK_STREAM, SOL_TCP);
42var_dump(socket_shutdown($socket,0));
43
44$socketConn = socket_connect($socket, $host, $port);
45var_dump(socket_shutdown($socket,-1));
46socket_close($socket);
47?>
48--CLEAN--
49<?php
50unset($host);
51unset($port);
52unset($socket);
53unset($socketConn);
54?>
55--EXPECTF--
56bool(true)
57bool(true)
58bool(true)
59
60Warning: socket_shutdown(): Unable to shutdown socket [%d]: A request to send or receive data was disallowed because the socket is not connected and (when sending on a datagram socket using a sendto call) no address was supplied in %s on line %d
61bool(false)
62
63Warning: socket_shutdown(): Unable to shutdown socket [%d]: An invalid argument was supplied in %s on line %d
64bool(false)
65