nlopess Sat Jul 16 12:53:28 2005 EDT
Modified files: /phpdoc/en/appendices wrappers.xml Log: document the new (PHP 5.1) 'bindto' socket context option http://cvs.php.net/diff.php/phpdoc/en/appendices/wrappers.xml?r1=1.51&r2=1.52&ty=u Index: phpdoc/en/appendices/wrappers.xml diff -u phpdoc/en/appendices/wrappers.xml:1.51 phpdoc/en/appendices/wrappers.xml:1.52 --- phpdoc/en/appendices/wrappers.xml:1.51 Thu Jul 14 08:31:00 2005 +++ phpdoc/en/appendices/wrappers.xml Sat Jul 16 12:53:27 2005 @@ -1,5 +1,5 @@ <?xml version="1.0" encoding="iso-8859-1"?> -<!-- $Revision: 1.51 $ --> +<!-- $Revision: 1.52 $ --> <appendix id="wrappers"> <title>List of Supported Protocols/Wrappers</title> <para> @@ -95,6 +95,59 @@ </para> </section> + <section id="wrappers.socket"> + <title>Socket</title> + <para> + This section contains the context option supported on wrappers that work + over sockets, like <literal>tcp</literal>, <literal>http</literal> or + <literal>ftp</literal>. + </para> + <para> + As of PHP 5.1.0 only one option is supported, <literal>bindto</literal>, + which can be used to specify the IP address (either IPv4 or IPv6) and/or + the port number that PHP will use to access the network. The syntax is + <literal>ip:port number</literal> (you can set the IP or the port number to + <literal>0</literal> if you want to let the system choose them for you). + </para> + <note> + <para> + As FTP creates two socket connections during normal operation, you cannot + specify the port number in the <literal>bindto</literal> option. So, the + only supported syntax is <literal>ip:0</literal> for the FTP wrapper. + </para> + </note> + <example> + <title>Some examples of how to use the bindto option</title> + <programlisting role="php"> +<![CDATA[ +<?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 port '7000' +$opts = array('socket' => + array('bindto' => '0:7000')); + + +// create the context... +$context = stream_context_create($opts); + +// ...and use it to fetch the data +echo file_get_contents('http://www.example.com', false, $context); + +?> +]]> + </programlisting> + </example> + </section> + <section id="wrappers.http"> <title>HTTP and HTTPS</title> <simpara>PHP 3, PHP 4, PHP 5. <filename>https://</filename> since PHP 4.3.0</simpara>