summaryrefslogtreecommitdiff
path: root/ext/sockets/tests
diff options
context:
space:
mode:
authorStanislav Malyshev <stas@php.net>2013-06-23 15:26:30 -0700
committerStanislav Malyshev <stas@php.net>2013-06-23 15:26:30 -0700
commite02b41d25c0b6cbbce56e097beae2dfe92626587 (patch)
tree81609926e3c75cf07853d140fbd538c3a99ff753 /ext/sockets/tests
parentc593b42a0c3ce1c9f28897c5fb4bb80fd8b6d5e6 (diff)
parent1beb24bd6f5376a93c062218a73a5f1d5f04278a (diff)
downloadphp-git-e02b41d25c0b6cbbce56e097beae2dfe92626587.tar.gz
Merge branch 'PHP-5.5'
* PHP-5.5: Implements feature Bug #63472 ability to set SO_BINDTODEVICE on socket.
Diffstat (limited to 'ext/sockets/tests')
-rw-r--r--ext/sockets/tests/socket_set_option_bindtodevice.phpt40
1 files changed, 40 insertions, 0 deletions
diff --git a/ext/sockets/tests/socket_set_option_bindtodevice.phpt b/ext/sockets/tests/socket_set_option_bindtodevice.phpt
new file mode 100644
index 0000000000..05d718ce63
--- /dev/null
+++ b/ext/sockets/tests/socket_set_option_bindtodevice.phpt
@@ -0,0 +1,40 @@
+--TEST--
+Test if socket_set_option() works, option:SO_BINDTODEVICE
+--DESCRIPTION--
+-Bind to loopback 'lo' device (should exist)
+-Bind to unexisting device
+--SKIPIF--
+<?php
+if (!extension_loaded('sockets')) {
+ die('SKIP sockets extension not available.');
+}
+if (!defined("SO_BINDTODEVICE")) {
+ die('SKIP SO_BINDTODEVICE not supported on this platform.');
+}
+if (!function_exists("posix_getuid") || posix_getuid() != 0) {
+ die('SKIP SO_BINDTODEVICE requires root permissions.');
+}
+?>
+--FILE--
+<?php
+$socket = socket_create(AF_INET, SOCK_STREAM, SOL_TCP);
+
+if (!$socket) {
+ die('Unable to create AF_INET socket [socket]');
+}
+// wrong params
+$retval_1 = socket_set_option( $socket, SOL_SOCKET, SO_BINDTODEVICE, "lo");
+var_dump($retval_1);
+$retval_2 = socket_set_option( $socket, SOL_SOCKET, SO_BINDTODEVICE, "ethIDONOTEXIST");
+var_dump($retval_2);
+
+socket_close($socket);
+?>
+
+--EXPECTF--
+bool(true)
+
+Warning: socket_set_option(): unable to set socket option [19]: No such device in %s on line %d
+bool(false)
+--CREDITS--
+Damjan Cvetko, foreach.org