aidan           Thu Feb 24 02:09:28 2005 EDT

  Modified files:              
    /phpdoc/en/reference/sockets/functions      socket-bind.xml 
  Log:
  Updated to new docskel. Added example.
  
http://cvs.php.net/diff.php/phpdoc/en/reference/sockets/functions/socket-bind.xml?r1=1.6&r2=1.7&ty=u
Index: phpdoc/en/reference/sockets/functions/socket-bind.xml
diff -u phpdoc/en/reference/sockets/functions/socket-bind.xml:1.6 
phpdoc/en/reference/sockets/functions/socket-bind.xml:1.7
--- phpdoc/en/reference/sockets/functions/socket-bind.xml:1.6   Sun Feb 13 
09:19:01 2005
+++ phpdoc/en/reference/sockets/functions/socket-bind.xml       Thu Feb 24 
02:09:27 2005
@@ -1,57 +1,142 @@
 <?xml version="1.0" encoding="iso-8859-1"?>
-<!-- $Revision: 1.6 $ -->
-<!-- splitted from ./en/functions/sockets.xml, last change in rev 1.3 -->
-  <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>bool</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>
-    <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
-     resource 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>
-     &return.success; The error code can be retrieved with
-     <function>socket_last_error</function>. This code may be passed to
-     <function>socket_strerror</function> to get a textual explanation of the
-     error. Note that <function>socket_last_error</function> is reported to
-     return an invalid error code in case you are trying to bind the socket
-     to a wrong address that does not belong to your Windows 9x/ME machine.
-    </para>
-    <para>
-     See also
-     <function>socket_connect</function>,
-     <function>socket_listen</function>,
-     <function>socket_create</function>,
-     <function>socket_last_error</function> and
-     <function>socket_strerror</function>.
-    </para>
-   </refsect1>
-  </refentry>
+<!-- $Revision: 1.7 $ -->
+<refentry id="function.socket-bind">
+ <refnamediv>
+  <refname>socket_bind</refname>
+  <refpurpose>Binds a name to a socket</refpurpose>
+ </refnamediv>
+
+ <refsect1 role="description">
+  &reftitle.description;
+  <methodsynopsis>
+   <type>bool</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>
+  <para>
+   Binds the name given in <parameter>address</parameter> to the socket
+   described by <parameter>socket</parameter>.
+  </para>
+ </refsect1>
+
+ <refsect1 role="parameters">
+  &reftitle.parameters;
+  <para>
+   <variablelist>
+    <varlistentry>
+     <term><parameter>socket</parameter></term>
+     <listitem>
+      <para>
+       A valid socket resource created with <function>socket_create</function>.
+      </para>
+     </listitem>
+    </varlistentry>
+    <varlistentry>
+     <term><parameter>address</parameter></term>
+     <listitem>
+      <para>
+       If the socket is of the <constant>AF_INET</constant> family, the
+       <parameter>address</parameter> is an IP in dotted-quad notation
+       (e.g. <literal>127.0.0.1</literal>).
+      </para>
+      <para>
+       If the socket is of the <constant>AF_UNIX</constant> family, the
+       <parameter>address</parameter> is the pathname of a
+       Unix-domain socket (e.g. <filename>/tmp/my.sock</filename>).
+      </para>
+     </listitem>
+    </varlistentry>
+    <varlistentry>
+     <term><parameter>port</parameter> (Optional)</term>
+     <listitem>
+      <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>
+     </listitem>
+    </varlistentry>
+   </variablelist>
+  </para>
+ </refsect1>
+
+ <refsect1 role="returnvalues">
+  &reftitle.returnvalues;
+  <para>&return.success;</para>
+  <para>
+   The error code can be retrieved with <function>socket_last_error</function>.
+   This code may be passed to <function>socket_strerror</function> to get a
+   textual explanation of the error.
+  </para>
+  <note>
+   <para>
+    Windows 9x/ME compatability note:
+    <function>socket_last_error</function> may return an invalid error code
+    if trying to bind the socket to a wrong address that does not belong to
+    your machine.
+   </para>
+  </note>
+ </refsect1>
+
+ <refsect1 role="examples">
+  &reftitle.examples;
+  <para>
+   <example>
+    <title>Using <function>socket_bind</function> to set the source 
address</title>
+    <programlisting role="php">
+<![CDATA[
+<?php
+// Create a new socket
+$sock = socket_create(AF_INET, SOCK_STREAM, SOL_TCP);
+
+// An example list of IP addresses owned by the computer
+$sourceips['kenny']    = '127.0.0.1';
+$sourceips['madcoder'] = '127.0.0.2';
+
+// Bind the source address
+socket_bind($sock, $computerips['madcoder']);
+
+// Connect to destination address
+socket_connect($sock, '127.0.0.1', 80);
+
+// Write
+socket_write($sock, "GET / HTTP/1.1\r\n\r\n");
+
+// Close
+socket_close($sock);
+
+?> 
+]]>
+    </programlisting>
+   </example>
+  </para>
+ </refsect1>
+
+ <refsect1 role="notes">
+  &reftitle.notes;
+  <note>
+   <para>
+    This function must be used on the socket before
+    <function>socket_connect</function>.
+   </para>
+  </note>
+ </refsect1>
+
+ <refsect1 role="seealso">
+  &reftitle.seealso;
+  <para>
+   <simplelist>
+    <member><function>socket_connect</function></member>
+    <member><function>socket_listen</function></member>
+    <member><function>socket_create</function></member>
+    <member><function>socket_last_error</function></member>
+    <member><function>socket_strerror</function></member>
+   </simplelist>
+  </para>
+ </refsect1>
+</refentry>
 
 <!-- Keep this comment at the end of the file
 Local variables:
@@ -72,4 +157,4 @@
 vim600: syn=xml fen fdm=syntax fdl=2 si
 vim: et tw=78 syn=sgml
 vi: ts=1 sw=1
--->
+-->
\ No newline at end of file

Reply via email to