mirror of
https://github.com/sigmasternchen/php-doc-en
synced 2025-03-16 08:58:56 +00:00
document the new (PHP 5.1) 'bindto' socket context option
git-svn-id: https://svn.php.net/repository/phpdoc/en/trunk@190809 c90b9560-bf6c-de11-be94-00142212c4b1
This commit is contained in:
parent
4bb0466627
commit
06b425d401
1 changed files with 54 additions and 1 deletions
|
@ -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>
|
||||
|
|
Loading…
Reference in a new issue