2010-03-28 22:10:10 +00:00
|
|
|
<?xml version="1.0" encoding="utf-8"?>
|
2009-07-11 08:54:10 +00:00
|
|
|
<!-- $Revision$ -->
|
2007-06-20 22:25:43 +00:00
|
|
|
<refentry xmlns="http://docbook.org/ns/docbook" xml:id="function.socket-sendto">
|
2007-06-15 00:16:44 +00:00
|
|
|
<refnamediv>
|
|
|
|
<refname>socket_sendto</refname>
|
|
|
|
<refpurpose>Sends a message to a socket, whether it is connected or not </refpurpose>
|
|
|
|
</refnamediv>
|
2007-06-15 00:16:46 +00:00
|
|
|
|
|
|
|
<refsect1 role="description">
|
|
|
|
&reftitle.description;
|
2007-06-15 00:16:44 +00:00
|
|
|
<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>
|
2009-01-16 12:08:51 +00:00
|
|
|
<methodparam choice="opt"><type>int</type><parameter>port</parameter><initializer>0</initializer></methodparam>
|
2007-06-15 00:16:44 +00:00
|
|
|
</methodsynopsis>
|
|
|
|
<para>
|
|
|
|
The function <function>socket_sendto</function> sends
|
|
|
|
<parameter>len</parameter> bytes from <parameter>buf</parameter>
|
|
|
|
through the socket <parameter>socket</parameter> to the
|
2007-07-03 00:48:19 +00:00
|
|
|
<parameter>port</parameter> at the address <parameter>addr</parameter>.
|
2007-06-15 00:16:44 +00:00
|
|
|
</para>
|
2007-06-15 00:16:46 +00:00
|
|
|
</refsect1>
|
|
|
|
|
|
|
|
<refsect1 role="parameters">
|
|
|
|
&reftitle.parameters;
|
2007-06-15 00:16:44 +00:00
|
|
|
<para>
|
2007-06-15 00:16:46 +00:00
|
|
|
<variablelist>
|
|
|
|
<varlistentry>
|
|
|
|
<term><parameter>socket</parameter></term>
|
|
|
|
<listitem>
|
|
|
|
<para>
|
2008-12-16 04:22:48 +00:00
|
|
|
A valid socket resource created using <function>socket_create</function>.
|
2007-06-15 00:16:46 +00:00
|
|
|
</para>
|
|
|
|
</listitem>
|
|
|
|
</varlistentry>
|
|
|
|
<varlistentry>
|
|
|
|
<term><parameter>buf</parameter></term>
|
|
|
|
<listitem>
|
|
|
|
<para>
|
2007-07-03 00:48:19 +00:00
|
|
|
The sent data will be taken from buffer <parameter>buf</parameter>.
|
2007-06-15 00:16:46 +00:00
|
|
|
</para>
|
|
|
|
</listitem>
|
|
|
|
</varlistentry>
|
|
|
|
<varlistentry>
|
|
|
|
<term><parameter>len</parameter></term>
|
|
|
|
<listitem>
|
|
|
|
<para>
|
2007-07-03 00:48:19 +00:00
|
|
|
<parameter>len</parameter> bytes from <parameter>buf</parameter> will be
|
|
|
|
sent.
|
2007-06-15 00:16:46 +00:00
|
|
|
</para>
|
|
|
|
</listitem>
|
|
|
|
</varlistentry>
|
|
|
|
<varlistentry>
|
|
|
|
<term><parameter>flags</parameter></term>
|
|
|
|
<listitem>
|
|
|
|
<para>
|
2007-08-17 15:17:30 +00:00
|
|
|
The value of <parameter>flags</parameter> can be any combination of
|
|
|
|
the following flags, joined with the binary OR (<literal>|</literal>)
|
|
|
|
operator.
|
2007-06-15 00:16:46 +00:00
|
|
|
<table>
|
2007-08-17 15:17:30 +00:00
|
|
|
<title>Possible values for <parameter>flags</parameter></title>
|
2007-06-15 00:16:46 +00:00
|
|
|
<tgroup cols="2">
|
|
|
|
<tbody>
|
|
|
|
<row>
|
2007-07-03 00:48:19 +00:00
|
|
|
<entry><constant>MSG_OOB</constant></entry>
|
2007-06-15 00:16:46 +00:00
|
|
|
<entry>
|
2007-08-17 15:17:30 +00:00
|
|
|
Send OOB (out-of-band) data.
|
2007-06-15 00:16:46 +00:00
|
|
|
</entry>
|
|
|
|
</row>
|
|
|
|
<row>
|
2007-08-17 15:17:30 +00:00
|
|
|
<entry><constant>MSG_EOR</constant></entry>
|
2007-06-15 00:16:46 +00:00
|
|
|
<entry>
|
2007-08-17 15:17:30 +00:00
|
|
|
Indicate a record mark. The sent data completes the record.
|
|
|
|
</entry>
|
|
|
|
</row>
|
|
|
|
<row>
|
|
|
|
<entry><constant>MSG_EOF</constant></entry>
|
|
|
|
<entry>
|
|
|
|
Close the sender side of the socket and include an appropriate
|
|
|
|
notification of this at the end of the sent data. The sent data
|
|
|
|
completes the transaction.
|
2007-06-15 00:16:46 +00:00
|
|
|
</entry>
|
|
|
|
</row>
|
|
|
|
<row>
|
2007-07-03 00:48:19 +00:00
|
|
|
<entry><constant>MSG_DONTROUTE</constant></entry>
|
2007-06-15 00:16:46 +00:00
|
|
|
<entry>
|
|
|
|
Bypass routing, use direct interface.
|
|
|
|
</entry>
|
|
|
|
</row>
|
|
|
|
</tbody>
|
|
|
|
</tgroup>
|
|
|
|
</table>
|
|
|
|
</para>
|
|
|
|
</listitem>
|
|
|
|
</varlistentry>
|
|
|
|
<varlistentry>
|
|
|
|
<term><parameter>addr</parameter></term>
|
|
|
|
<listitem>
|
|
|
|
<para>
|
2007-07-03 00:48:19 +00:00
|
|
|
IP address of the remote host.
|
2007-06-15 00:16:46 +00:00
|
|
|
</para>
|
|
|
|
</listitem>
|
|
|
|
</varlistentry>
|
|
|
|
<varlistentry>
|
|
|
|
<term><parameter>port</parameter></term>
|
|
|
|
<listitem>
|
|
|
|
<para>
|
2007-07-03 00:48:19 +00:00
|
|
|
<parameter>port</parameter> is the remote port number at which the data
|
|
|
|
will be sent.
|
2007-06-15 00:16:46 +00:00
|
|
|
</para>
|
|
|
|
</listitem>
|
|
|
|
</varlistentry>
|
|
|
|
</variablelist>
|
2007-06-15 00:16:44 +00:00
|
|
|
</para>
|
2007-06-15 00:16:46 +00:00
|
|
|
</refsect1>
|
|
|
|
|
|
|
|
<refsect1 role="returnvalues">
|
|
|
|
&reftitle.returnvalues;
|
|
|
|
<para>
|
2007-07-03 00:48:19 +00:00
|
|
|
<function>socket_sendto</function> returns the number of bytes sent to the
|
2009-01-29 14:05:48 +00:00
|
|
|
remote host, or &false; if an error occurred.
|
2007-06-15 00:16:46 +00:00
|
|
|
</para>
|
|
|
|
</refsect1>
|
|
|
|
|
|
|
|
|
|
|
|
<refsect1 role="examples">
|
|
|
|
&reftitle.examples;
|
|
|
|
<para>
|
|
|
|
<example>
|
|
|
|
<title><function>socket_sendto</function> Example</title>
|
|
|
|
<programlisting role="php">
|
2003-05-28 21:56:04 +00:00
|
|
|
<![CDATA[
|
|
|
|
<?php
|
2007-07-21 17:55:08 +00:00
|
|
|
$sock = socket_create(AF_INET, SOCK_DGRAM, SOL_UDP);
|
|
|
|
|
|
|
|
$msg = "Ping !";
|
|
|
|
$len = strlen($msg);
|
|
|
|
|
|
|
|
socket_sendto($sock, $msg, $len, 0, '127.0.0.1', 1223);
|
|
|
|
socket_close($sock);
|
2003-05-28 21:56:04 +00:00
|
|
|
?>
|
|
|
|
]]>
|
2007-06-15 00:16:46 +00:00
|
|
|
</programlisting>
|
|
|
|
</example>
|
|
|
|
</para>
|
|
|
|
</refsect1>
|
|
|
|
|
|
|
|
<refsect1 role="seealso">
|
|
|
|
&reftitle.seealso;
|
2007-06-15 00:16:44 +00:00
|
|
|
<para>
|
2007-06-15 00:16:46 +00:00
|
|
|
<simplelist>
|
|
|
|
<member><function>socket_send</function></member>
|
|
|
|
</simplelist>
|
2007-06-15 00:16:44 +00:00
|
|
|
</para>
|
|
|
|
</refsect1>
|
2007-06-15 00:16:46 +00:00
|
|
|
|
2007-06-15 00:16:44 +00:00
|
|
|
</refentry>
|
2002-04-15 00:12:54 +00:00
|
|
|
|
|
|
|
<!-- 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
|
2009-09-25 07:04:39 +00:00
|
|
|
sgml-default-dtd-file:"~/.phpdoc/manual.ced"
|
2002-04-15 00:12:54 +00:00
|
|
|
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
|
|
|
|
-->
|