]> granicus.if.org Git - php/commitdiff
test to function socket_shutdown();
authormarcosptf <marcosptf@yahoo.com.br>
Mon, 16 Nov 2015 21:39:06 +0000 (19:39 -0200)
committerJulien Pauli <jpauli@php.net>
Thu, 24 Dec 2015 12:04:38 +0000 (13:04 +0100)
ext/sockets/tests/socket_shutdown.phpt [new file with mode: 0644]

diff --git a/ext/sockets/tests/socket_shutdown.phpt b/ext/sockets/tests/socket_shutdown.phpt
new file mode 100644 (file)
index 0000000..09f5ac7
--- /dev/null
@@ -0,0 +1,54 @@
+--TEST--
+bool socket_shutdown ( resource $socket [, int $how = 2 ] ) ;
+--CREDITS--
+marcosptf - <marcosptf@yahoo.com.br> - #phparty7 - @phpsp - novatec/2015 - sao paulo - br
+--SKIPIF--
+<?php
+if (!extension_loaded('sockets')) {
+  die('SKIP sockets extension not available.');
+}
+?>
+--FILE--
+<?php
+$host = "yahoo.com";
+$port = 80;
+
+$socket = socket_create(AF_INET, SOCK_STREAM, SOL_TCP);
+$socketConn = socket_connect($socket, $host, $port);
+var_dump(socket_shutdown($socket,0));
+socket_close($socket);
+
+$socket = socket_create(AF_INET, SOCK_STREAM, SOL_TCP);
+$socketConn = socket_connect($socket, $host, $port);
+var_dump(socket_shutdown($socket,1));
+socket_close($socket);
+
+$socket = socket_create(AF_INET, SOCK_STREAM, SOL_TCP);
+$socketConn = socket_connect($socket, $host, $port);
+var_dump(socket_shutdown($socket,2));
+socket_close($socket);
+
+$socket = socket_create(AF_INET, SOCK_STREAM, SOL_TCP);
+var_dump(socket_shutdown($socket,0));
+
+$socketConn = socket_connect($socket, $host, $port);
+var_dump(socket_shutdown($socket,-1));
+socket_close($socket);
+?>
+--CLEAN--
+<?php
+unset($host);
+unset($port);
+unset($socket);
+unset($socketConn);
+?>
+--EXPECTF--
+bool(true)
+bool(true)
+bool(true)
+
+Warning: socket_shutdown(): unable to shutdown socket [%d]: Transport endpoint is not connected in %s on line %d
+bool(false)
+
+Warning: socket_shutdown(): unable to shutdown socket [%d]: Invalid argument in %s on line %d
+bool(false)