Socket context option listing
Socket context options are available for all wrappers that work over sockets, like tcp, http and ftp.
Changelog:
5.3.3
Added backlog.
5.1.0
Added bindto.
Examples:
Basic bindto usage example
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 | <?php // connect to the internet using the '192.168.0.100' IP $opts = array ( 'socket' => array ( 'bindto' => '192.168.0.100:0' , ), ); // connect to the internet using the '192.168.0.100' IP and port '7000' $opts = array ( 'socket' => array ( 'bindto' => '192.168.0.100:7000' , ), ); // connect to the internet using the '2001:db8::1' IPv6 address // and port '7000' $opts = array ( 'socket' => array ( 'bindto' => '[2001:db8::1]:7000' , ), ); // connect to the internet using port '7000' $opts = array ( 'socket' => array ( 'bindto' => '0:7000' , ), ); // create the context... $context = stream_context_create( $opts ); // ...and use it to fetch the data ?> |
Please login to continue.