1--TEST-- 2Test if socket_set_option() works, option:SO_BINDTODEVICE 3--DESCRIPTION-- 4-Bind to loopback 'lo' device (should exist) 5-Bind to unexisting device 6--SKIPIF-- 7<?php 8if (!extension_loaded('sockets')) { 9 die('SKIP sockets extension not available.'); 10} 11if (!defined("SO_BINDTODEVICE")) { 12 die('SKIP SO_BINDTODEVICE not supported on this platform.'); 13} 14if (!function_exists("posix_getuid") || posix_getuid() != 0) { 15 die('SKIP SO_BINDTODEVICE requires root permissions.'); 16} 17?> 18--FILE-- 19<?php 20$socket = socket_create(AF_INET, SOCK_STREAM, SOL_TCP); 21 22if (!$socket) { 23 die('Unable to create AF_INET socket [socket]'); 24} 25// wrong params 26$retval_1 = socket_set_option( $socket, SOL_SOCKET, SO_BINDTODEVICE, "lo"); 27var_dump($retval_1); 28$retval_2 = socket_set_option( $socket, SOL_SOCKET, SO_BINDTODEVICE, "ethIDONOTEXIST"); 29var_dump($retval_2); 30 31socket_close($socket); 32?> 33--EXPECTF-- 34bool(true) 35 36Warning: socket_set_option(): unable to set socket option [19]: No such device in %s on line %d 37bool(false) 38--CREDITS-- 39Damjan Cvetko, foreach.org 40