mirror of
https://github.com/sigmasternchen/php-doc-en
synced 2025-03-16 17:08:54 +00:00
Added info on UDP support and a simple example that connects to the datetime
service git-svn-id: https://svn.php.net/repository/phpdoc/en/trunk@29871 c90b9560-bf6c-de11-be94-00142212c4b1
This commit is contained in:
parent
c2411a77f8
commit
a1ef6ebcd6
1 changed files with 31 additions and 9 deletions
|
@ -119,7 +119,9 @@
|
|||
<funcsynopsis>
|
||||
<funcprototype>
|
||||
<funcdef>int <function>fsockopen</function></funcdef>
|
||||
<paramdef>string <parameter>hostname</parameter></paramdef>
|
||||
<paramdef>
|
||||
string <parameter><optional>udp://</optional>hostname</parameter>
|
||||
</paramdef>
|
||||
<paramdef>int <parameter>port</parameter></paramdef>
|
||||
<paramdef>int
|
||||
<parameter><optional>errno</optional></parameter>
|
||||
|
@ -133,14 +135,17 @@
|
|||
</funcprototype>
|
||||
</funcsynopsis>
|
||||
<para>
|
||||
Initiates a stream connection in the Internet (AF_INET) or Unix
|
||||
(AF_UNIX) domain. For the Internet domain, it will open a TCP
|
||||
socket connection to <parameter>hostname</parameter> on port
|
||||
<parameter>port</parameter>. For the Unix domain,
|
||||
<parameter>hostname</parameter> will be used as the path to the
|
||||
socket, <parameter>port</parameter> must be set to 0 in this
|
||||
case. The optional <parameter>timeout</parameter> can be used to
|
||||
set a timeout in seconds for the connect system call.
|
||||
Initiates a stream connection in the Internet (AF_INET, using
|
||||
TCP or UDP) or Unix (AF_UNIX) domain. For the Internet domain,
|
||||
it will open a TCP
|
||||
socket connection to <parameter>hostname</parameter> on
|
||||
port <parameter>port</parameter>. For UDP connections, you need
|
||||
to explicitely specify the the protocol:
|
||||
<parameter>udp://hostname</parameter>. For the Unix domain,
|
||||
<parameter>hostname</parameter> will be used as the path to the
|
||||
socket, <parameter>port</parameter> must be set to 0 in this
|
||||
case. The optional <parameter>timeout</parameter> can be used
|
||||
to set a timeout in seconds for the connect system call.
|
||||
</para>
|
||||
<para>
|
||||
<function>Fsockopen</function> returns a file pointer which may
|
||||
|
@ -185,6 +190,23 @@ if (!$fp) {
|
|||
}
|
||||
</programlisting>
|
||||
</example>
|
||||
The example below shows how to retrieve the day and time
|
||||
from the UDP service "daytime" (port 13) in your own machine.
|
||||
<example>
|
||||
<title>Using UDP connection</title>
|
||||
<programlisting role="php">
|
||||
<?php
|
||||
$fp = fsockopen("udp://127.0.0.1",13, &$errno; &$errstr);
|
||||
if (!fp) {
|
||||
echo "ERROR: $errno - $errstr<br>\n";
|
||||
} else {
|
||||
fwrite($fp,"\n");
|
||||
echo fread($fp, 26);
|
||||
fclose($fp);
|
||||
}
|
||||
?>
|
||||
</programlisting>
|
||||
</example>
|
||||
See also: <function>pfsockopen</function>
|
||||
</para>
|
||||
</refsect1>
|
||||
|
|
Loading…
Reference in a new issue