php-doc-en/functions/network.sgml
cslawi 9256eb3b12 Normalized according to the DocBook 3.1 DTD. This mostly just adds
closing tags and attribute quotes, but lets a stock 3.1 install
compile the PHP docs. It still compiles with DocBook 3.0, as well.


git-svn-id: https://svn.php.net/repository/phpdoc/en/trunk@14693 c90b9560-bf6c-de11-be94-00142212c4b1
1999-10-20 22:41:42 +00:00

402 lines
14 KiB
Text

<reference id="ref.network">
<title>Network functions</title>
<titleabbrev>Network</titleabbrev>
<refentry id="function.checkdnsrr">
<refnamediv>
<refname>checkdnsrr</refname>
<refpurpose>Check DNS records corresponding to a given
Internet host name or IP address.</refpurpose>
</refnamediv>
<refsect1>
<title>Description</title>
<funcsynopsis>
<funcdef>int <function>checkdnsrr</function></funcdef>
<paramdef>string <parameter>host</parameter></paramdef>
<paramdef>string <parameter><optional>type</optional></parameter></paramdef>
</funcsynopsis>
<simpara>
Searches DNS for records of type <parameter>type</parameter>
corresponding to <parameter>host</parameter>. Returns true if any
records are found; returns false if no records were found or if
an error occurred.</simpara>
<simpara>
<parameter>type</parameter> may be any one of: A, MX, NS, SOA,
PTR, CNAME, or ANY. The default is MX.</simpara>
<simpara>
<parameter>host</parameter> may either be the IP address in
dotted-quad notation or the host name.</simpara>
<simpara>
See also
<function>getmxrr</function>,
<function>gethostbyaddr</function>,
<function>gethostbyname</function>,
<function>gethostbynamel</function>, and
the named(8) manual page.</simpara>
</refsect1>
</refentry>
<refentry id="function.closelog">
<refnamediv>
<refname>closelog</refname>
<refpurpose>close connection to system logger</refpurpose>
</refnamediv>
<refsect1>
<title>Description</title>
<funcsynopsis>
<funcdef>int <function>closelog</function></funcdef>
<void>
</funcsynopsis>
<para>
<function>closelog</function> closes the descriptor being used to
write to the system logger. The use of
<function>closelog</function> is optional.</para>
</refsect1>
</refentry>
<refentry id="function.debugger-off">
<refnamediv>
<refname>debugger_off</refname>
<refpurpose>disable internal PHP debugger</refpurpose>
</refnamediv>
<refsect1>
<title>Description</title>
<funcsynopsis>
<funcdef>int <function>debugger_off</function></funcdef>
<void>
</funcsynopsis>
<para>
Disables the internal PHP debugger. The debugger is still under
development.</para>
</refsect1>
</refentry>
<refentry id="function.debugger-on">
<refnamediv>
<refname>debugger_on</refname>
<refpurpose>enable internal PHP debugger</refpurpose>
</refnamediv>
<refsect1>
<title>Description</title>
<funcsynopsis>
<funcdef>int <function>debugger_on</function></funcdef>
<paramdef>string <parameter>address</parameter></paramdef>
</funcsynopsis>
<para>
Enables the internal PHP debugger, connecting it to
<parameter>address</parameter>. The debugger is still under
development.</para>
</refsect1>
</refentry>
<refentry id="function.fsockopen">
<refnamediv>
<refname>fsockopen</refname>
<refpurpose>Open Internet or Unix domain socket connection.</refpurpose>
</refnamediv>
<refsect1>
<title>Description</title>
<funcsynopsis>
<funcdef>int <function>fsockopen</function></funcdef>
<paramdef>string <parameter>hostname</parameter></paramdef>
<paramdef>int <parameter>port</parameter></paramdef>
<paramdef>int <parameter><optional>errno</optional></parameter></paramdef>
<paramdef>string <parameter><optional>errstr</optional></parameter></paramdef>
<paramdef>double
<parameter><optional>timeout</optional></parameter></paramdef>
</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.</para>
<para>
<function>fsockopen</function> returns a file pointer which may be used
together with the other file functions (such as
<function>fgets</function>, <function>fgetss</function>,
<function>fputs</function>, <function>fclose</function>,
<function>feof</function>).</para>
<para>
If the call fails, it will return false and if the optional
<parameter>errno</parameter> and <parameter>errstr</parameter> arguments
are present they will be set to indicate the actual system level error
that occurred on the system-level connect() call. If the returned errno is
0 and the function returned false, it is an indication that the error
occurred before the connect() call. This is most likely due to a problem
initializing the socket. Note that the errno and errstr arguments must be
passed by reference.</para>
<para>
Depending on the environment, the Unix domain or the optional connect
timeout may not be available.</para>
<para>
The socket will by default be opened in blocking mode. You can switch it
to non-blocking mode by using <function>set_socket_blocking</function>.
<example>
<title>fsockopen example</title>
<programlisting>
$fp = fsockopen("www.php.net", 80, &$errno, &$errstr, 30);
if(!$fp) {
echo "$errstr ($errno)&lt;br&gt;\n";
} else {
fputs($fp,"GET / HTTP/1.0\n\n");
while(!feof($fp)) {
echo fgets($fp,128);
}
fclose($fp);
}
</programlisting>
</example>
See also: <function>pfsockopen</function></para>
</refsect1>
</refentry>
<refentry id="function.gethostbyaddr">
<refnamediv>
<refname>gethostbyaddr</refname>
<refpurpose>Get the Internet host name corresponding to a given
IP address.</refpurpose>
</refnamediv>
<refsect1>
<title>Description</title>
<funcsynopsis>
<funcdef>string <function>gethostbyaddr</function></funcdef>
<paramdef>string <parameter>ip_address</parameter></paramdef>
</funcsynopsis>
<para>
Returns the host name of the Internet host specified by
<parameter>ip_address</parameter>. If an error occurs, returns
<parameter>ip_address</parameter>.</para>
<para>
See also <function>gethostbyname</function>.</para>
</refsect1>
</refentry>
<refentry id="function.gethostbyname">
<refnamediv>
<refname>gethostbyname</refname>
<refpurpose>Get the IP address corresponding to a given
Internet host name.</refpurpose>
</refnamediv>
<refsect1>
<title>Description</title>
<funcsynopsis>
<funcdef>string <function>gethostbyname</function></funcdef>
<paramdef>string <parameter>hostname</parameter></paramdef>
</funcsynopsis>
<para>
Returns the IP address of the Internet host specified by
<parameter>hostname</parameter>.</para>
<para>
See also <function>gethostbyaddr</function>.</para>
</refsect1>
</refentry>
<refentry id="function.gethostbynamel">
<refnamediv>
<refname>gethostbynamel</refname>
<refpurpose>Get a list of IP addresses corresponding to a given
Internet host name.</refpurpose>
</refnamediv>
<refsect1>
<title>Description</title>
<funcsynopsis>
<funcdef>array <function>gethostbynamel</function></funcdef>
<paramdef>string <parameter>hostname</parameter></paramdef>
</funcsynopsis>
<para>
Returns a list of IP addresses to which the Internet host
specified by <parameter>hostname</parameter> resolves.</para>
<para>
See also
<function>gethostbyname</function>,
<function>gethostbyaddr</function>,
<function>checkdnsrr</function>,
<function>getmxrr</function>, and
the named(8) manual page.</para>
</refsect1>
</refentry>
<refentry id="function.getmxrr">
<refnamediv>
<refname>getmxrr</refname>
<refpurpose>Get MX records corresponding to a given
Internet host name.</refpurpose>
</refnamediv>
<refsect1>
<title>Description</title>
<funcsynopsis>
<funcdef>int <function>getmxrr</function></funcdef>
<paramdef>string <parameter>hostname</parameter></paramdef>
<paramdef>array <parameter>mxhosts</parameter></paramdef>
<paramdef>array <parameter><optional>weight</optional></parameter></paramdef>
</funcsynopsis>
<simpara>
Searches DNS for MX records corresponding to
<parameter>hostname</parameter>. Returns true if any records are
found; returns false if no records were found or if an error occurred.</simpara>
<simpara>
A list of the MX records found is placed into the array
<parameter>mxhosts</parameter>. If the
<parameter>weight</parameter> array is given, it will be filled
with the weight information gathered.</simpara>
<simpara>
See also
<function>checkdnsrr</function>,
<function>gethostbyname</function>,
<function>gethostbynamel</function>,
<function>gethostbyaddr</function>, and
the named(8) manual page.</simpara>
</refsect1>
</refentry>
<refentry id="function.openlog">
<refnamediv>
<refname>openlog</refname>
<refpurpose>open connection to system logger</refpurpose>
</refnamediv>
<refsect1>
<title>Description</title>
<funcsynopsis>
<funcdef>int <function>openlog</function></funcdef>
<paramdef>string <parameter>ident</parameter></paramdef>
<paramdef>int <parameter>option</parameter></paramdef>
<paramdef>int <parameter>facility</parameter></paramdef>
</funcsynopsis>
<para>
<function>openlog</function> opens a connection to the system
logger for a program. The string <parameter>ident</parameter> is
added to each message. Values for <parameter>option</parameter>
and <parameter>facility</parameter> are given in the next
section. The use of openlog() is optional; It will automatically
be called by <function>syslog</function> if necessary, in which
case ident will default to <literal>false</literal>.
See also <function>syslog</function> and
<function>closelog</function>.</para>
</refsect1>
</refentry>
<refentry id="function.pfsockopen">
<refnamediv>
<refname>pfsockopen</refname>
<refpurpose>Open persistent Internet or Unix domain socket connection.</refpurpose>
</refnamediv>
<refsect1>
<title>Description</title>
<funcsynopsis>
<funcdef>int <function>pfsockopen</function></funcdef>
<paramdef>string <parameter>hostname</parameter></paramdef>
<paramdef>int <parameter>port</parameter></paramdef>
<paramdef>int <parameter><optional>errno</optional></parameter></paramdef>
<paramdef>string <parameter><optional>errstr</optional></parameter></paramdef>
<paramdef>int
<parameter><optional>timeout</optional></parameter></paramdef>
</funcsynopsis>
<para>
This function behaves exactly as <function>fsockopen</function> with the
difference that the connection is not closed after the script finishes.
It is the persistent version of <function>fsockopen</function>.</para>
</refsect1>
</refentry>
<refentry id="function.set-socket-blocking">
<refnamediv>
<refname>set_socket_blocking</refname>
<refpurpose>Set blocking/non-blocking mode on a socket</refpurpose>
</refnamediv>
<refsect1>
<title>Description</title>
<funcsynopsis>
<funcdef>int <function>set_socket_blocking</function></funcdef>
<paramdef>int <parameter>socket descriptor</parameter></paramdef>
<paramdef>int <parameter>mode</parameter></paramdef>
</funcsynopsis>
<para>
If <parameter>mode</parameter> is false, the given socket
descriptor will be switched to non-blocking mode, and if true, it
will be switched to blocking mode. This affects calls like
<function>fgets</function> that read from the socket. In
non-blocking mode an fgets() call will always return right away
while in blocking mode it will wait for data to become available
on the socket.</para>
</refsect1>
</refentry>
<refentry id="function.syslog">
<refnamediv>
<refname>syslog</refname>
<refpurpose>generate a system log message</refpurpose>
</refnamediv>
<refsect1>
<title>Description</title>
<funcsynopsis>
<funcdef>int <function>syslog</function></funcdef>
<paramdef>int <parameter>priority</parameter></paramdef>
<paramdef>string <parameter>message</parameter></paramdef>
</funcsynopsis>
<para>
<function>syslog</function> generates a log message that will be
distributed by the system logger.
<parameter>priority</parameter> is a combination of the facility
and the level, values for which are given in the next section.
The remaining argument is the message to send, except that the
two characters <literal>%m</literal> will be replaced by the
error message string (strerror) corresponding to the present
value of <errortype>errno</errortype>.</para>
<para>
More information on the syslog facilities can be found in
the man pages for syslog on Unix machines.</para>
<para>
On Windows NT, the syslog service is emulated using the
Event Log.</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
sgml-parent-document:nil
sgml-default-dtd-file:"../manual.ced"
sgml-exposed-tags:nil
sgml-local-catalogs:nil
sgml-local-ecat-files:nil
End:
-->