php-doc-en/functions/sockets.xml
Hartmut Holzgraefe 7839d91186 added DO NOT EDIT noctice to old english functions files,
removing the others


git-svn-id: https://svn.php.net/repository/phpdoc/en/trunk@78562 c90b9560-bf6c-de11-be94-00142212c4b1
2002-04-17 19:58:46 +00:00

1223 lines
42 KiB
XML

<!-- D O N O T E D I T T H I S F I L E ! ! !
it is still here for historical reasons only
(as translators may need to check old revision diffs)
if you want to change things documented in this file
you should now edit the files found under en/reference
instead -->
<?xml version="1.0" encoding="iso-8859-1"?>
<!-- $Revision: 1.38 $ -->
<reference id="ref.sockets">
<title>Socket functions</title>
<titleabbrev>Sockets</titleabbrev>
<partintro>
&warn.experimental;
<simpara>
The socket extension implements a low-level interface to the
socket communication functions, providing the possibility to act
as a socket server as well as a client.
</simpara>
<para>
The socket functions described here are part of an extension to
PHP which must be enabled at compile time by giving the <option
role="configure">--enable-sockets</option> option to
<command>configure</command>.
</para>
<para>
For a more generic client-side socket interface, see
<function>fsockopen</function> and
<function>pfsockopen</function>.
</para>
<para>
When using these functions, it is important to remember that while
many of them have identical names to their C counterparts, they
often have different declarations. Please be sure to read the
descriptions to avoid confusion.
</para>
<para>
That said, those unfamiliar with socket programming can still find
a lot of useful material in the appropriate Unix man pages, and
there is a great deal of tutorial information on socket
programming in C on the web, much of which can be applied, with
slight modifications, to socket programming in PHP.
</para>
<para>
<example>
<title>Socket example: Simple TCP/IP server</title>
<para>
This example shows a simple talkback server. Change the
<varname>address</varname> and <varname>port</varname> variables
to suit your setup and execute. You may then connect to the
server with a command similar to: <command>telnet 192.168.1.53
10000</command> (where the address and port match your
setup). Anything you type will then be output on the server
side, and echoed back to you. To disconnect, enter 'quit'.
</para>
<programlisting role="php">
<![CDATA[
#!/usr/local/bin/php -q
<?php
error_reporting (E_ALL);
/* Allow the script to hang around waiting for connections. */
set_time_limit (0);
/* Turn on implicit output flushing so we see what we're getting
* as it comes in. */
ob_implicit_flush ();
$address = '192.168.1.53';
$port = 10000;
if (($sock = socket_create (AF_INET, SOCK_STREAM, 0)) < 0) {
echo "socket_create() failed: reason: " . socket_strerror ($sock) . "\n";
}
if (($ret = socket_bind ($sock, $address, $port)) < 0) {
echo "socket_bind() failed: reason: " . socket_strerror ($ret) . "\n";
}
if (($ret = socket_listen ($sock, 5)) < 0) {
echo "socket_listen() failed: reason: " . socket_strerror ($ret) . "\n";
}
do {
if (($msgsock = socket_accept($sock)) < 0) {
echo "socket_accept() failed: reason: " . socket_strerror ($msgsock) . "\n";
break;
}
/* Send instructions. */
$msg = "\nWelcome to the PHP Test Server. \n" .
"To quit, type 'quit'. To shut down the server type 'shutdown'.\n";
socket_write($msgsock, $msg, strlen($msg));
do {
if (FALSE === ($buf = socket_read ($msgsock, 2048))) {
echo "socket_read() failed: reason: " . socket_strerror ($ret) . "\n";
break 2;
}
if (!$buf = trim ($buf)) {
continue;
}
if ($buf == 'quit') {
break;
}
if ($buf == 'shutdown') {
socket_close ($msgsock);
break 2;
}
$talkback = "PHP: You said '$buf'.\n";
socket_write ($msgsock, $talkback, strlen ($talkback));
echo "$buf\n";
} while (true);
socket_close ($msgsock);
} while (true);
socket_close ($sock);
?>
]]>
</programlisting>
</example>
</para>
<para>
<example>
<title>Socket example: Simple TCP/IP client</title>
<para>
This example shows a simple, one-shot HTTP client. It simply
connects to a page, submits a HEAD request, echoes the reply,
and exits.
</para>
<programlisting>
<![CDATA[
<?php
error_reporting (E_ALL);
echo "<h2>TCP/IP Connection</h2>\n";
/* Get the port for the WWW service. */
$service_port = getservbyname ('www', 'tcp');
/* Get the IP address for the target host. */
$address = gethostbyname ('www.example.com');
/* Create a TCP/IP socket. */
$socket = socket_create (AF_INET, SOCK_STREAM, 0);
if ($socket < 0) {
echo "socket_create() failed: reason: " . socket_strerror ($socket) . "\n";
} else {
echo "OK.\n";
}
echo "Attempting to connect to '$address' on port '$service_port'...";
$result = socket_connect ($socket, $address, $service_port);
if ($result < 0) {
echo "socket_connect() failed.\nReason: ($result) " . socket_strerror($result) . "\n";
} else {
echo "OK.\n";
}
$in = "HEAD / HTTP/1.0\r\n\r\n";
$out = '';
echo "Sending HTTP HEAD request...";
socket_write ($socket, $in, strlen ($in));
echo "OK.\n";
echo "Reading response:\n\n";
while ($out = socket_read ($socket, 2048)) {
echo $out;
}
echo "Closing socket...";
socket_close ($socket);
echo "OK.\n\n";
?>
]]>
</programlisting>
</example>
</para>
</partintro>
<refentry id="function.socket-accept">
<refnamediv>
<refname>socket_accept</refname>
<refpurpose>Accepts a connection on a socket</refpurpose>
</refnamediv>
<refsect1>
<title>Description</title>
<methodsynopsis>
<type>int</type><methodname>socket_accept</methodname>
<methodparam><type>resource</type><parameter>socket</parameter></methodparam>
</methodsynopsis>
&warn.experimental.func;
<para>
After the socket <parameter>socket</parameter> has been created
using <function>socket_create</function>, bound to a name with
<function>socket_bind</function>, and told to listen for connections
with <function>socket_listen</function>, this function will accept
incoming connections on that socket. Once a successful connection
is made, a new socket descriptor is returned, which may be used
for communication. If there are multiple connections queued on
the socket, the first will be used. If there are no pending
connections, <function>socket_accept</function> will block until
a connection becomes present. If <parameter>socket</parameter>
has been made non-blocking using
<function>socket_set_blocking</function> or
<function>socket_set_nonblock</function>, an error code will be
returned.
</para>
<para>
The socket descriptor returned by
<function>socket_accept</function> may not be used to accept new
connections. The original listening socket
<parameter>socket</parameter>, however, remains open and may be
reused.
</para>
<para>
Returns a new socket descriptor on success, or a negative error
code on failure. This code may be passed to
<function>socket_strerror</function> to get a textual explanation of the
error.
</para>
<para>
See also
<function>socket_bind</function>,
<function>socket_connect</function>,
<function>socket_listen</function>,
<function>socket_create</function>, and
<function>socket_strerror</function>.
</para>
</refsect1>
</refentry>
<refentry id="function.socket-bind">
<refnamediv>
<refname>socket_bind</refname>
<refpurpose>Binds a name to a socket</refpurpose>
</refnamediv>
<refsect1>
<title>Description</title>
<methodsynopsis>
<type>int</type><methodname>socket_bind</methodname>
<methodparam><type>resource</type><parameter>socket</parameter></methodparam>
<methodparam><type>string</type><parameter>address</parameter></methodparam>
<methodparam choice="opt"><type>int</type><parameter>port</parameter></methodparam>
</methodsynopsis>
&warn.experimental.func;
<para>
<function>socket_bind</function> binds the name given in
<parameter>address</parameter> to the socket described by
<parameter>socket</parameter>, which must be a valid socket
descriptor created with <function>socket_create</function>.
</para>
<para>
The <parameter>address</parameter> parameter is either an IP
address in dotted-quad notation
(e.g. <literal>127.0.0.1</literal>), if the socket is of the
<constant>AF_INET</constant> family; or the pathname of a
Unix-domain socket, if the socket family is
<constant>AF_UNIX</constant>.
</para>
<para>
The <parameter>port</parameter> parameter is only used when
connecting to an <constant>AF_INET</constant> socket, and
designates the port on the remote host to which a connection
should be made.
</para>
<para>
Returns zero on success, or a negative error code on
failure. This code may be passed to <function>socket_strerror</function>
to get a textual explanation of the error.
</para>
<para>
See also
<function>socket_connect</function>,
<function>socket_listen</function>,
<function>socket_create</function>, and
<function>socket_strerror</function>.
</para>
</refsect1>
</refentry>
<refentry id="function.socket-close">
<refnamediv>
<refname>socket_close</refname>
<refpurpose>Closes a socket descriptor</refpurpose>
</refnamediv>
<refsect1>
<title>Description</title>
<methodsynopsis>
<type>bool</type><methodname>socket_close</methodname>
<methodparam><type>resource</type><parameter>socket</parameter></methodparam>
</methodsynopsis>
&warn.experimental.func;
<para>
<function>socket_close</function> closes the file (or socket) descriptor
given by <parameter>socket</parameter>.
</para>
<para>
Note that <function>socket_close</function> should not be used on PHP
file descriptors created with <function>fopen</function>,
<function>popen</function>, <function>fsockopen</function>, or
<function>psockopen</function>; it is meant for sockets created
with <function>socket_create</function> or
<function>socket_accept</function>.
</para>
<para>
Returns &true; on success, or &false;
if an error occurs (i.e., <parameter>socket</parameter> is invalid).
</para>
<para>
See also <function>socket_bind</function>, <function>socket_listen</function>,
<function>socket_create</function>, and
<function>socket_strerror</function>.
</para>
</refsect1>
</refentry>
<refentry id="function.socket-connect">
<refnamediv>
<refname>socket_connect</refname>
<refpurpose>Initiates a connection on a socket</refpurpose>
</refnamediv>
<refsect1>
<title>Description</title>
<methodsynopsis>
<type>int</type><methodname>socket_connect</methodname>
<methodparam><type>resource</type><parameter>socket</parameter></methodparam>
<methodparam><type>string</type><parameter>address</parameter></methodparam>
<methodparam choice="opt"><type>int</type><parameter>port</parameter></methodparam>
</methodsynopsis>
&warn.experimental.func;
<para>
Initiates a connection using the socket descriptor
<parameter>socket</parameter>, which must be a valid socket
descriptor created with <function>socket_create</function>.
</para>
<para>
The <parameter>address</parameter> parameter is either an IP
address in dotted-quad notation
(e.g. <literal>127.0.0.1</literal>), if the socket is of the
<constant>AF_INET</constant> family; or the pathname of a
Unix-domain socket, if the socket family is
<constant>AF_UNIX</constant>.
</para>
<para>
The <parameter>port</parameter> parameter is only used when
connecting to an <constant>AF_INET</constant> socket, and
designates the port on the remote host to which a connection
should be made.
</para>
<para>
Returns zero on success, or a negative error code on
failure. This code may be passed to <function>socket_strerror</function>
to get a textual explanation of the error.
</para>
<para>
See also
<function>socket_bind</function>,
<function>socket_listen</function>,
<function>socket_create</function>, and
<function>socket_strerror</function>.
</para>
</refsect1>
</refentry>
<refentry id="function.socket-listen">
<refnamediv>
<refname>socket_listen</refname>
<refpurpose>Listens for a connection on a socket</refpurpose>
</refnamediv>
<refsect1>
<title>Description</title>
<methodsynopsis>
<type>int</type><methodname>socket_listen</methodname>
<methodparam><type>resource</type><parameter>socket</parameter></methodparam>
<methodparam><type>int</type><parameter>backlog</parameter></methodparam>
</methodsynopsis>
&warn.experimental.func;
<para>
After the socket <parameter>socket</parameter> has been created
using <function>socket_create</function> and bound to a name with
<function>socket_bind</function>, it may be told to listen for incoming
connections on <parameter>socket</parameter>. A maximum of
<parameter>backlog</parameter> incoming connections will be
queued for processing.
</para>
<para>
<function>socket_listen</function> is applicable only to sockets with
type <literal>SOCK_STREAM</literal> or
<literal>SOCK_SEQPACKET</literal>.
</para>
<para>
Returns zero on success, or a negative error code on
failure. This code may be passed to <function>socket_strerror</function>
to get a textual explanation of the error.
</para>
<para>
See also
<function>socket_accept</function>,
<function>socket_bind</function>,
<function>socket_connect</function>,
<function>socket_create</function>, and
<function>socket_strerror</function>.
</para>
</refsect1>
</refentry>
<refentry id="function.socket-read">
<refnamediv>
<refname>socket_read</refname>
<refpurpose>Reads from a socket</refpurpose>
</refnamediv>
<refsect1>
<title>Description</title>
<methodsynopsis>
<type>string</type><methodname>socket_read</methodname>
<methodparam><type>resource</type><parameter>socket_des</parameter></methodparam>
<methodparam><type>int</type><parameter>length</parameter></methodparam>
<methodparam choice="opt"><type>int</type><parameter>type</parameter></methodparam>
</methodsynopsis>
&warn.experimental.func;
<para>
The function <function>socket_read</function> reads from socket
<parameter>socket_des</parameter> created by the
<function>socket_accept</function> function the number of bytes set by
<parameter>length</parameter>. Otherwise you can use \n, \t or \0 to
end reading. Returns data, or FALSE if
<function>socket_read</function> failed.
</para>
<para>
Optional <parameter>type</parameter> parameter is a named constant:
<itemizedlist>
<listitem>
<simpara>
PHP_BINARY_READ - use the system <function>socket_read</function>
(Default in PHP &gt;= 4.1.0)
</simpara>
</listitem>
<listitem>
<simpara>
PHP_NORMAL_READ - reading stops at \n or \r. (Default in PHP &lt;= 4.0.6)
</simpara>
</listitem>
</itemizedlist>
</para>
<para>
See also
<function>socket_accept</function>,
<function>socket_bind</function>,
<function>socket_connect</function>,
<function>socket_listen</function>,
<function>socket_strerror</function>, and
<function>socket_write</function>.
</para>
</refsect1>
</refentry>
<refentry id="function.socket-create">
<refnamediv>
<refname>socket_create</refname>
<refpurpose>Create a socket (endpoint for communication)</refpurpose>
</refnamediv>
<refsect1>
<title>Description</title>
<methodsynopsis>
<type>resource</type><methodname>socket_create</methodname>
<methodparam><type>int</type><parameter>domain</parameter></methodparam>
<methodparam><type>int</type><parameter>type</parameter></methodparam>
<methodparam><type>int</type><parameter>protocol</parameter></methodparam>
</methodsynopsis>
&warn.experimental.func;
<para>
Creates a communication endpoint (a socket), and returns a
descriptor to the socket.
</para>
<para>
The <parameter>domain</parameter> parameter sets the
domain. Currently, <constant>AF_INET</constant> and
<constant>AF_UNIX</constant> are understood.
</para>
<para>
The <parameter>type</parameter> parameter selects the socket
type. This is one of <constant>SOCK_STREAM</constant>,
<constant>SOCK_DGRAM</constant>,
<constant>SOCK_SEQPACKET</constant>,
<constant>SOCK_RAW</constant>, <constant>SOCK_RDM</constant>, or
<constant>SOCK_PACKET</constant>.
</para>
<para>
<parameter>protocol</parameter> sets the protocol.
</para>
<para>
Returns a valid socket descriptor on success, or a negative error
code on failure. This code may be passed to
<function>socket_strerror</function> to get a textual explanation of the
error.
</para>
<para>
For more information on the usage of <function>socket_create</function>,
as well as on the meanings of the various parameters, see the
Unix man page socket (2).
</para>
<para>
See also
<function>socket_accept</function>,
<function>socket_bind</function>,
<function>socket_connect</function>,
<function>socket_listen</function>, and
<function>socket_strerror</function>.
</para>
</refsect1>
</refentry>
<refentry id="function.socket-strerror">
<refnamediv>
<refname>socket_strerror</refname>
<refpurpose>Return a string describing a socket error</refpurpose>
</refnamediv>
<refsect1>
<title>Description</title>
<methodsynopsis>
<type>string</type><methodname>socket_strerror</methodname>
<methodparam><type>int</type><parameter>errno</parameter></methodparam>
</methodsynopsis>
&warn.experimental.func;
<para>
<function>socket_strerror</function> takes as its
<parameter>errno</parameter> parameter the return value of one of
the socket functions, and returns the corresponding explanatory
text. This makes it a bit more pleasant to figure out why
something didn't work; for instance, instead of having to track
down a system include file to find out what '-111' means, you
just pass it to <function>socket_strerror</function>, and it tells you
what happened.
</para>
<para>
<example>
<title><function>socket_strerror</function> example</title>
<programlisting role="php">
<![CDATA[
<?php
if (($socket = socket_create (AF_INET, SOCK_STREAM, 0)) < 0) {
echo "socket_create() failed: reason: " . socket_strerror ($socket) . "\n";
}
if (($ret = socket_bind ($socket, '127.0.0.1', 80)) < 0) {
echo "socket_bind() failed: reason: " . socket_strerror ($ret) . "\n";
}
?>
]]>
</programlisting>
<para>
The expected output from the above example (assuming the script
is not run with root privileges):
<screen>
bind() failed: reason: Permission denied
</screen>
</para>
</example>
</para>
<para>
See also
<function>socket_accept</function>,
<function>socket_bind</function>,
<function>socket_connect</function>,
<function>socket_listen</function>, and
<function>socket_create</function>.
</para>
</refsect1>
</refentry>
<refentry id="function.socket-write">
<refnamediv>
<refname>socket_write</refname>
<refpurpose>Write to a socket</refpurpose>
</refnamediv>
<refsect1>
<title>Description</title>
<methodsynopsis>
<type>int</type><methodname>socket_write</methodname>
<methodparam><type>resource</type><parameter>socket_des</parameter></methodparam>
<methodparam><type>string</type><parameter>&amp;buffer</parameter></methodparam>
<methodparam><type>int</type><parameter>length</parameter></methodparam>
</methodsynopsis>
&warn.experimental.func;
<para>
The function <function>socket_write</function> writes to the socket
<parameter>socket_des</parameter> from
<parameter>&amp;buffer</parameter> the number of bytes set by
<parameter>length</parameter>.
</para>
<para>
See also
<function>socket_accept</function>,
<function>socket_bind</function>,
<function>socket_connect</function>,
<function>socket_listen</function>,
<function>socket_read</function>, and
<function>socket_strerror</function>.
</para>
</refsect1>
</refentry>
<refentry id="function.socket-fd-alloc">
<refnamediv>
<refname>socket_fd_alloc</refname>
<refpurpose>Allocates a new file descriptor set </refpurpose>
</refnamediv>
<refsect1>
<title>Description</title>
<methodsynopsis>
<type>resource</type><methodname>socket_fd_alloc</methodname>
<void/>
</methodsynopsis>
&warn.experimental.func;
<para>
&warn.undocumented.func;
</para>
</refsect1>
</refentry>
<refentry id="function.socket-fd-free">
<refnamediv>
<refname>socket_fd_free</refname>
<refpurpose>Deallocates a file descriptor set </refpurpose>
</refnamediv>
<refsect1>
<title>Description</title>
<methodsynopsis>
<type>bool</type><methodname>socket_fd_free</methodname>
<methodparam><type>resource</type><parameter>set</parameter></methodparam>
</methodsynopsis>
&warn.experimental.func;
<para>
&warn.undocumented.func;
</para>
</refsect1>
</refentry>
<refentry id="function.socket-fd-set">
<refnamediv>
<refname>socket_fd_set</refname>
<refpurpose>Adds (a) file descriptor(s) to a set </refpurpose>
</refnamediv>
<refsect1>
<title>Description</title>
<methodsynopsis>
<type>bool</type><methodname>socket_fd_set</methodname>
<methodparam><type>resource</type><parameter>set</parameter></methodparam>
<methodparam><type>mixed</type><parameter>socket</parameter></methodparam>
</methodsynopsis>
&warn.experimental.func;
<para>
&warn.undocumented.func;
</para>
</refsect1>
</refentry>
<refentry id="function.socket-fd-clear">
<refnamediv>
<refname>socket_fd_clear</refname>
<refpurpose>Clears (a) file descriptor(s) from a set </refpurpose>
</refnamediv>
<refsect1>
<title>Description</title>
<methodsynopsis>
<type>bool</type><methodname>socket_fd_clear</methodname>
<methodparam><type>resource</type><parameter>set</parameter></methodparam>
<methodparam><type>mixed</type><parameter>socket</parameter></methodparam>
</methodsynopsis>
&warn.experimental.func;
<para>
&warn.undocumented.func;
</para>
</refsect1>
</refentry>
<refentry id="function.socket-fd-isset">
<refnamediv>
<refname>socket_fd_isset</refname>
<refpurpose>Checks to see if a file descriptor is set within the file descrirptor set </refpurpose>
</refnamediv>
<refsect1>
<title>Description</title>
<methodsynopsis>
<type>bool</type><methodname>socket_fd_isset</methodname>
<methodparam><type>resource</type><parameter>set</parameter></methodparam>
<methodparam><type>resource</type><parameter>socket</parameter></methodparam>
</methodsynopsis>
&warn.experimental.func;
<para>
&warn.undocumented.func;
</para>
</refsect1>
</refentry>
<refentry id="function.socket-fd-zero">
<refnamediv>
<refname>socket_fd_zero</refname>
<refpurpose>Clears a file descriptor set </refpurpose>
</refnamediv>
<refsect1>
<title>Description</title>
<methodsynopsis>
<type>bool</type><methodname>socket_fd_zero</methodname>
<methodparam><type>resource</type><parameter>set</parameter></methodparam>
</methodsynopsis>
&warn.experimental.func;
<para>
&warn.undocumented.func;
</para>
</refsect1>
</refentry>
<refentry id="function.socket-select">
<refnamediv>
<refname>socket_select</refname>
<refpurpose>Runs the select() system call on the sets mentioned with a timeout specified by tv_sec and tv_usec </refpurpose>
</refnamediv>
<refsect1>
<title>Description</title>
<methodsynopsis>
<type>int</type><methodname>socket_select</methodname>
<methodparam><type>resource</type><parameter>read_fd</parameter></methodparam>
<methodparam><type>resource</type><parameter>write_fd</parameter></methodparam>
<methodparam><type>resource</type><parameter>except_fd</parameter></methodparam>
<methodparam><type>int</type><parameter>tv_sec</parameter></methodparam>
<methodparam choice="opt"><type>int</type><parameter>tv_usec</parameter></methodparam>
</methodsynopsis>
&warn.experimental.func;
<para>
&warn.undocumented.func;
</para>
</refsect1>
</refentry>
<refentry id="function.socket-create-listen">
<refnamediv>
<refname>socket_create_listen</refname>
<refpurpose>Opens a socket on port to accept connections </refpurpose>
</refnamediv>
<refsect1>
<title>Description</title>
<methodsynopsis>
<type>resource</type><methodname>socket_create_listen</methodname>
<methodparam><type>int</type><parameter>port</parameter></methodparam>
<methodparam choice="opt"><type>int</type><parameter>backlog</parameter></methodparam>
</methodsynopsis>
&warn.experimental.func;
<para>
&warn.undocumented.func;
</para>
</refsect1>
</refentry>
<refentry id="function.socket-set-nonblock">
<refnamediv>
<refname>socket_set_nonblock</refname>
<refpurpose>Sets nonblocking mode for file descriptor fd </refpurpose>
</refnamediv>
<refsect1>
<title>Description</title>
<methodsynopsis>
<type>bool</type><methodname>socket_set_nonblock</methodname>
<methodparam><type>resource</type><parameter>socket</parameter></methodparam>
</methodsynopsis>
&warn.experimental.func;
<para>
&warn.undocumented.func;
</para>
</refsect1>
</refentry>
<refentry id="function.socket-getsockname">
<refnamediv>
<refname>socket_getsockname</refname>
<refpurpose>Given an fd, stores a string representing sa.sin_addr and the value of sa.sin_port into addr and port describing the local side of a socket </refpurpose>
</refnamediv>
<refsect1>
<title>Description</title>
<methodsynopsis>
<type>bool</type><methodname>socket_getsockname</methodname>
<methodparam><type>resource</type><parameter>socket</parameter></methodparam>
<methodparam><type>string</type><parameter>&amp;addr</parameter></methodparam>
<methodparam choice="opt"><type>int</type><parameter>&amp;port</parameter></methodparam>
</methodsynopsis>
&warn.experimental.func;
<para>
&warn.undocumented.func;
</para>
</refsect1>
</refentry>
<refentry id="function.socket-getpeername">
<refnamediv>
<refname>socket_getpeername</refname>
<refpurpose>Given an fd, stores a string representing sa.sin_addr and the value of sa.sin_port into addr and port describing the remote side of a socket </refpurpose>
</refnamediv>
<refsect1>
<title>Description</title>
<methodsynopsis>
<type>bool</type><methodname>socket_getpeername</methodname>
<methodparam><type>resource</type><parameter>socket</parameter></methodparam>
<methodparam><type>string</type><parameter>&amp;addr</parameter></methodparam>
<methodparam choice="opt"><type>int</type><parameter>&amp;port</parameter></methodparam>
</methodsynopsis>
&warn.experimental.func;
<para>
&warn.undocumented.func;
</para>
</refsect1>
</refentry>
<refentry id="function.socket-iovec-alloc">
<refnamediv>
<refname>socket_iovec_alloc</refname>
<refpurpose>...]) Builds a 'struct iovec' for use with sendmsg, recvmsg, writev, and readv </refpurpose>
</refnamediv>
<refsect1>
<title>Description</title>
<methodsynopsis>
<type>resource</type><methodname>socket_iovec_alloc</methodname>
<methodparam><type>int</type><parameter>num_vectors</parameter></methodparam>
<methodparam choice="opt"><type>int</type><parameter/></methodparam>
</methodsynopsis>
&warn.experimental.func;
<para>
&warn.undocumented.func;
</para>
</refsect1>
</refentry>
<refentry id="function.socket-iovec-fetch">
<refnamediv>
<refname>socket_iovec_fetch</refname>
<refpurpose>Returns the data held in the iovec specified by iovec_id[iovec_position] </refpurpose>
</refnamediv>
<refsect1>
<title>Description</title>
<methodsynopsis>
<type>string</type><methodname>socket_iovec_fetch</methodname>
<methodparam><type>resource</type><parameter>iovec</parameter></methodparam>
<methodparam><type>int</type><parameter>iovec_position</parameter></methodparam>
</methodsynopsis>
&warn.experimental.func;
<para>
&warn.undocumented.func;
</para>
</refsect1>
</refentry>
<refentry id="function.socket-iovec-set">
<refnamediv>
<refname>socket_iovec_set</refname>
<refpurpose>Sets the data held in iovec_id[iovec_position] to new_val </refpurpose>
</refnamediv>
<refsect1>
<title>Description</title>
<methodsynopsis>
<type>bool</type><methodname>socket_iovec_set</methodname>
<methodparam><type>resource</type><parameter>iovec</parameter></methodparam>
<methodparam><type>int</type><parameter>iovec_position</parameter></methodparam>
<methodparam><type>string</type><parameter>new_val</parameter></methodparam>
</methodsynopsis>
&warn.experimental.func;
<para>
&warn.undocumented.func;
</para>
</refsect1>
</refentry>
<refentry id="function.socket-iovec-add">
<refnamediv>
<refname>socket_iovec_add</refname>
<refpurpose>Adds a new vector to the scatter/gather array </refpurpose>
</refnamediv>
<refsect1>
<title>Description</title>
<methodsynopsis>
<type>bool</type><methodname>socket_iovec_add</methodname>
<methodparam><type>resource</type><parameter>iovec</parameter></methodparam>
<methodparam><type>int</type><parameter>iov_len</parameter></methodparam>
</methodsynopsis>
&warn.experimental.func;
<para>
&warn.undocumented.func;
</para>
</refsect1>
</refentry>
<refentry id="function.socket-iovec-delete">
<refnamediv>
<refname>socket_iovec_delete</refname>
<refpurpose>Deletes a vector from an array of vectors </refpurpose>
</refnamediv>
<refsect1>
<title>Description</title>
<methodsynopsis>
<type>bool</type><methodname>socket_iovec_delete</methodname>
<methodparam><type>resource</type><parameter>iovec</parameter></methodparam>
<methodparam><type>int</type><parameter>iov_pos</parameter></methodparam>
</methodsynopsis>
&warn.experimental.func;
<para>
&warn.undocumented.func;
</para>
</refsect1>
</refentry>
<refentry id="function.socket-iovec-free">
<refnamediv>
<refname>socket_iovec_free</refname>
<refpurpose>Frees the iovec specified by iovec_id </refpurpose>
</refnamediv>
<refsect1>
<title>Description</title>
<methodsynopsis>
<type>bool</type><methodname>socket_iovec_free</methodname>
<methodparam><type>resource</type><parameter>iovec</parameter></methodparam>
</methodsynopsis>
&warn.experimental.func;
<para>
&warn.undocumented.func;
</para>
</refsect1>
</refentry>
<refentry id="function.socket-readv">
<refnamediv>
<refname>socket_readv</refname>
<refpurpose>Reads from an fd, using the scatter-gather array defined by iovec_id </refpurpose>
</refnamediv>
<refsect1>
<title>Description</title>
<methodsynopsis>
<type>bool</type><methodname>socket_readv</methodname>
<methodparam><type>resource</type><parameter>socket</parameter></methodparam>
<methodparam><type>resource</type><parameter>iovec_id</parameter></methodparam>
</methodsynopsis>
&warn.experimental.func;
<para>
&warn.undocumented.func;
</para>
</refsect1>
</refentry>
<refentry id="function.socket-writev">
<refnamediv>
<refname>socket_writev</refname>
<refpurpose>Writes to a file descriptor, fd, using the scatter-gather array defined by iovec_id </refpurpose>
</refnamediv>
<refsect1>
<title>Description</title>
<methodsynopsis>
<type>bool</type><methodname>socket_writev</methodname>
<methodparam><type>resource</type><parameter>socket</parameter></methodparam>
<methodparam><type>resource</type><parameter>iovec_id</parameter></methodparam>
</methodsynopsis>
&warn.experimental.func;
<para>
&warn.undocumented.func;
</para>
</refsect1>
</refentry>
<refentry id="function.socket-recv">
<refnamediv>
<refname>socket_recv</refname>
<refpurpose>Receives data from a connected socket </refpurpose>
</refnamediv>
<refsect1>
<title>Description</title>
<methodsynopsis>
<type>string</type><methodname>socket_recv</methodname>
<methodparam><type>resource</type><parameter>socket</parameter></methodparam>
<methodparam><type>int</type><parameter>len</parameter></methodparam>
<methodparam><type>int</type><parameter>flags</parameter></methodparam>
</methodsynopsis>
&warn.experimental.func;
<para>
&warn.undocumented.func;
</para>
</refsect1>
</refentry>
<refentry id="function.socket-send">
<refnamediv>
<refname>socket_send</refname>
<refpurpose>Sends data to a connected socket </refpurpose>
</refnamediv>
<refsect1>
<title>Description</title>
<methodsynopsis>
<type>int</type><methodname>socket_send</methodname>
<methodparam><type>resource</type><parameter>socket</parameter></methodparam>
<methodparam><type>string</type><parameter>buf</parameter></methodparam>
<methodparam><type>int</type><parameter>len</parameter></methodparam>
<methodparam><type>int</type><parameter>flags</parameter></methodparam>
</methodsynopsis>
&warn.experimental.func;
<para>
&warn.undocumented.func;
</para>
</refsect1>
</refentry>
<refentry id="function.socket-recvfrom">
<refnamediv>
<refname>socket_recvfrom</refname>
<refpurpose>Receives data from a socket, connected or not </refpurpose>
</refnamediv>
<refsect1>
<title>Description</title>
<methodsynopsis>
<type>int</type><methodname>socket_recvfrom</methodname>
<methodparam><type>resource</type><parameter>socket</parameter></methodparam>
<methodparam><type>string</type><parameter>&amp;buf</parameter></methodparam>
<methodparam><type>int</type><parameter>len</parameter></methodparam>
<methodparam><type>int</type><parameter>flags</parameter></methodparam>
<methodparam><type>string</type><parameter>&amp;name</parameter></methodparam>
<methodparam choice="opt"><type>int</type><parameter>&amp;port</parameter></methodparam>
</methodsynopsis>
&warn.experimental.func;
<para>
&warn.undocumented.func;
</para>
</refsect1>
</refentry>
<refentry id="function.socket-sendto">
<refnamediv>
<refname>socket_sendto</refname>
<refpurpose>Sends a message to a socket, whether it is connected or not </refpurpose>
</refnamediv>
<refsect1>
<title>Description</title>
<methodsynopsis>
<type>int</type><methodname>socket_sendto</methodname>
<methodparam><type>resource</type><parameter>socket</parameter></methodparam>
<methodparam><type>string</type><parameter>buf</parameter></methodparam>
<methodparam><type>int</type><parameter>len</parameter></methodparam>
<methodparam><type>int</type><parameter>flags</parameter></methodparam>
<methodparam><type>string</type><parameter>addr</parameter></methodparam>
<methodparam choice="opt"><type>int</type><parameter>port</parameter></methodparam>
</methodsynopsis>
&warn.experimental.func;
<para>
&warn.undocumented.func;
</para>
</refsect1>
</refentry>
<refentry id="function.socket-recvmsg">
<refnamediv>
<refname>socket_recvmsg</refname>
<refpurpose>Used to receive messages on a socket, whether connection-oriented or not </refpurpose>
</refnamediv>
<refsect1>
<title>Description</title>
<methodsynopsis>
<type>bool</type><methodname>socket_recvmsg</methodname>
<methodparam><type>resource</type><parameter>socket</parameter></methodparam>
<methodparam><type>resource</type><parameter>iovec</parameter></methodparam>
<methodparam><type>array</type><parameter>&amp;control</parameter></methodparam>
<methodparam><type>int</type><parameter>&amp;controllen</parameter></methodparam>
<methodparam><type>int</type><parameter>&amp;flags</parameter></methodparam>
<methodparam><type>string</type><parameter>&amp;addr</parameter></methodparam>
<methodparam choice="opt"><type>int</type><parameter>&amp;port</parameter></methodparam>
</methodsynopsis>
&warn.experimental.func;
<para>
&warn.undocumented.func;
</para>
</refsect1>
</refentry>
<refentry id="function.socket-sendmsg">
<refnamediv>
<refname>socket_sendmsg</refname>
<refpurpose>Sends a message to a socket, regardless of whether it is connection-oriented or not </refpurpose>
</refnamediv>
<refsect1>
<title>Description</title>
<methodsynopsis>
<type>bool</type><methodname>socket_sendmsg</methodname>
<methodparam><type>resource</type><parameter>socket</parameter></methodparam>
<methodparam><type>resource</type><parameter>iovec</parameter></methodparam>
<methodparam><type>int</type><parameter>flags</parameter></methodparam>
<methodparam><type>string</type><parameter>addr</parameter></methodparam>
<methodparam choice="opt"><type>int</type><parameter>port</parameter></methodparam>
</methodsynopsis>
&warn.experimental.func;
<para>
&warn.undocumented.func;
</para>
</refsect1>
</refentry>
<refentry id="function.socket-getopt">
<refnamediv>
<refname>socket_getopt</refname>
<refpurpose>Gets socket options for the socket </refpurpose>
</refnamediv>
<refsect1>
<title>Description</title>
<methodsynopsis>
<type>mixed</type><methodname>socket_getopt</methodname>
<methodparam><type>resource</type><parameter>socket</parameter></methodparam>
<methodparam><type>int</type><parameter>level</parameter></methodparam>
<methodparam><type>int</type><parameter>optname</parameter></methodparam>
</methodsynopsis>
&warn.experimental.func;
<para>
&warn.undocumented.func;
</para>
</refsect1>
</refentry>
<refentry id="function.socket-setopt">
<refnamediv>
<refname>socket_setopt</refname>
<refpurpose>Sets socket options for the socket</refpurpose>
</refnamediv>
<refsect1>
<title>Description</title>
<methodsynopsis>
<type>bool</type><methodname>socket_setopt</methodname>
<methodparam><type>resource</type><parameter>socket</parameter></methodparam>
<methodparam><type>int</type><parameter>level</parameter></methodparam>
<methodparam><type>int</type><parameter>optname</parameter></methodparam>
<methodparam><type>int</type><parameter/></methodparam>
</methodsynopsis>
&warn.experimental.func;
<para>
&warn.undocumented.func;
</para>
</refsect1>
</refentry>
<refentry id="function.socket-create-pair">
<refnamediv>
<refname>socket_create_pair</refname>
<refpurpose>Creates a pair of indistinguishable sockets and stores them in fds. </refpurpose>
</refnamediv>
<refsect1>
<title>Description</title>
<methodsynopsis>
<type>bool</type><methodname>socket_create_pair</methodname>
<methodparam><type>int</type><parameter>domain</parameter></methodparam>
<methodparam><type>int</type><parameter>type</parameter></methodparam>
<methodparam><type>int</type><parameter>protocol</parameter></methodparam>
<methodparam><type>array</type><parameter>&amp;fd</parameter></methodparam>
</methodsynopsis>
&warn.experimental.func;
<para>
&warn.undocumented.func;
</para>
</refsect1>
</refentry>
<refentry id="function.socket-shutdown">
<refnamediv>
<refname>socket_shutdown</refname>
<refpurpose>Shuts down a socket for receiving, sending, or both. </refpurpose>
</refnamediv>
<refsect1>
<title>Description</title>
<methodsynopsis>
<type>bool</type><methodname>socket_shutdown</methodname>
<methodparam><type>resource</type><parameter>socket</parameter></methodparam>
<methodparam choice="opt"><type>int</type><parameter>how</parameter></methodparam>
</methodsynopsis>
&warn.experimental.func;
<para>
&warn.undocumented.func;
</para>
</refsect1>
</refentry>
<refentry id="function.socket-last-error">
<refnamediv>
<refname>socket_last_error</refname>
<refpurpose>Returns/Clears the last error on the socket </refpurpose>
</refnamediv>
<refsect1>
<title>Description</title>
<methodsynopsis>
<type>int</type><methodname>socket_last_error</methodname>
<methodparam><type>resource</type><parameter>socket</parameter></methodparam>
</methodsynopsis>
&warn.experimental.func;
<para>
&warn.undocumented.func;
</para>
</refsect1>
</refentry>
</reference>
<!-- Keep this comment at the end of the file
Local variables:
mode: sgml
sgml-omittag:t
sgml-shorttag:t
sgml-minimize-attributes:nil
sgml-always-quote-attributes:t
sgml-indent-step:1
sgml-indent-data:t
indent-tabs-mode:nil
sgml-parent-document:nil
sgml-default-dtd-file:"../../manual.ced"
sgml-exposed-tags:nil
sgml-local-catalogs:nil
sgml-local-ecat-files:nil
End:
vim600: syn=xml fen fdm=syntax fdl=2 si
vim: et tw=78 syn=sgml
vi: ts=1 sw=1
-->