mirror of
https://github.com/sigmasternchen/php-doc-en
synced 2025-03-17 01:18:55 +00:00

removing the others git-svn-id: https://svn.php.net/repository/phpdoc/en/trunk@78562 c90b9560-bf6c-de11-be94-00142212c4b1
1002 lines
32 KiB
XML
1002 lines
32 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.63 $ -->
|
|
<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>
|
|
<methodsynopsis>
|
|
<type>int</type><methodname>checkdnsrr</methodname>
|
|
<methodparam><type>string</type><parameter>host</parameter></methodparam>
|
|
<methodparam choice="opt"><type>string</type><parameter>type</parameter></methodparam>
|
|
</methodsynopsis>
|
|
<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>
|
|
¬e.no-windows;
|
|
<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>
|
|
<methodsynopsis>
|
|
<type>int</type><methodname>closelog</methodname>
|
|
<void/>
|
|
</methodsynopsis>
|
|
<para>
|
|
<function>closelog</function> closes the descriptor being used to
|
|
write to the system logger. The use of
|
|
<function>closelog</function> is optional.
|
|
</para>
|
|
<para>
|
|
See also <function>define_syslog_variables</function>,
|
|
<function>syslog</function> and
|
|
<function>openlog</function>.
|
|
</para>
|
|
</refsect1>
|
|
</refentry>
|
|
|
|
<refentry id="function.debugger-off">
|
|
<refnamediv>
|
|
<refname>debugger_off</refname>
|
|
<refpurpose>Disable internal PHP debugger</refpurpose>
|
|
</refnamediv>
|
|
<refsect1>
|
|
<title>Description</title>
|
|
<methodsynopsis>
|
|
<type>int</type><methodname>debugger_off</methodname>
|
|
<void/>
|
|
</methodsynopsis>
|
|
<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>
|
|
<methodsynopsis>
|
|
<type>int</type><methodname>debugger_on</methodname>
|
|
<methodparam><type>string</type><parameter>address</parameter></methodparam>
|
|
</methodsynopsis>
|
|
<para>
|
|
Enables the internal PHP debugger, connecting it to
|
|
<parameter>address</parameter>. The debugger is still under
|
|
development.
|
|
</para>
|
|
</refsect1>
|
|
</refentry>
|
|
|
|
<refentry id="function.define-syslog-variables">
|
|
<refnamediv>
|
|
<refname>define_syslog_variables</refname>
|
|
<refpurpose>Initializes all syslog related constants</refpurpose>
|
|
</refnamediv>
|
|
<refsect1>
|
|
<title>Description</title>
|
|
<methodsynopsis>
|
|
<type>void</type><methodname>define_syslog_variables</methodname>
|
|
<void/>
|
|
</methodsynopsis>
|
|
<para>
|
|
Initializes all constants used in the syslog functions.
|
|
</para>
|
|
<para>
|
|
See also <function>openlog</function>,
|
|
<function>syslog</function> and
|
|
<function>closelog</function>.
|
|
</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>
|
|
<methodsynopsis>
|
|
<type>int</type><methodname>fsockopen</methodname>
|
|
<methodparam><type>string</type><parameter>hostname</parameter></methodparam>
|
|
<methodparam><type>int</type><parameter>port</parameter></methodparam>
|
|
<methodparam choice="opt"><type>int</type><parameter>errno</parameter></methodparam>
|
|
<methodparam choice="opt"><type>string</type><parameter>errstr</parameter></methodparam>
|
|
<methodparam choice="opt"><type>float</type><parameter>timeout</parameter></methodparam>
|
|
</methodsynopsis>
|
|
<para>
|
|
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>. <parameter>hostname</parameter> may
|
|
in this case be either a fully qualified domain name or an IP
|
|
address. For UDP connections, you need to explicitly specify the
|
|
protocol by prefixing <parameter>hostname</parameter> with
|
|
'<literal>udp://</literal>'. 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>
|
|
As of PHP 4.3.0, if you have compiled in OpenSSL support, you may
|
|
prefix the <parameter>hostname</parameter> with either
|
|
'<literal>ssl://</literal>' or '<literal>tls://</literal>' to
|
|
use an SSL or TLS client connection over TCP/IP to connect
|
|
to the remote host.
|
|
</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>, and
|
|
<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 in the system-level
|
|
<literal>connect()</literal> call. If the value returned in
|
|
<parameter>errno</parameter> is <literal>0</literal> and the
|
|
function returned &false;, it is an indication that the error
|
|
occurred before the <literal>connect()</literal> call. This is
|
|
most likely due to a problem initializing the socket. Note that
|
|
the <parameter>errno</parameter> and
|
|
<parameter>errstr</parameter> arguments will always 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>socket_set_blocking</function>.
|
|
<example>
|
|
<title><function>fsockopen</function> Example</title>
|
|
<programlisting role="php">
|
|
<![CDATA[
|
|
<?php
|
|
$fp = fsockopen ("www.example.com", 80, $errno, $errstr, 30);
|
|
if (!$fp) {
|
|
echo "$errstr ($errno)<br>\n";
|
|
} else {
|
|
fputs ($fp, "GET / HTTP/1.0\r\nHost: www.example.com\r\n\r\n");
|
|
while (!feof($fp)) {
|
|
echo fgets ($fp,128);
|
|
}
|
|
fclose ($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">
|
|
<![CDATA[
|
|
<?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>
|
|
<note>
|
|
<para>The timeout parameter was introduced in PHP 3.0.9 and
|
|
UDP support was added in PHP 4.
|
|
</para>
|
|
</note>
|
|
See also <function>pfsockopen</function>,
|
|
<function>socket_set_blocking</function>,
|
|
<function>socket_set_timeout</function>, <function>fgets</function>,
|
|
<function>fgetss</function>, <function>fputs</function>,
|
|
<function>fclose</function>, <function>feof</function>, and
|
|
the <link linkend="ref.curl">Curl extension</link>.
|
|
</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>
|
|
<methodsynopsis>
|
|
<type>string</type><methodname>gethostbyaddr</methodname>
|
|
<methodparam><type>string</type><parameter>ip_address</parameter></methodparam>
|
|
</methodsynopsis>
|
|
<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>
|
|
<methodsynopsis>
|
|
<type>string</type><methodname>gethostbyname</methodname>
|
|
<methodparam><type>string</type><parameter>hostname</parameter></methodparam>
|
|
</methodsynopsis>
|
|
<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>
|
|
<methodsynopsis>
|
|
<type>array</type><methodname>gethostbynamel</methodname>
|
|
<methodparam><type>string</type><parameter>hostname</parameter></methodparam>
|
|
</methodsynopsis>
|
|
<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 <literal>named(8)</literal> 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>
|
|
<methodsynopsis>
|
|
<type>int</type><methodname>getmxrr</methodname>
|
|
<methodparam><type>string</type><parameter>hostname</parameter></methodparam>
|
|
<methodparam><type>array</type><parameter>mxhosts</parameter></methodparam>
|
|
<methodparam choice="opt"><type>array</type><parameter>weight</parameter></methodparam>
|
|
</methodsynopsis>
|
|
<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
|
|
<literal>named(8)</literal> manual page.
|
|
</simpara>
|
|
</refsect1>
|
|
</refentry>
|
|
|
|
<refentry id="function.getprotobyname">
|
|
<refnamediv>
|
|
<refname>getprotobyname</refname>
|
|
<refpurpose>
|
|
Get protocol number associated with protocol name
|
|
</refpurpose>
|
|
</refnamediv>
|
|
<refsect1>
|
|
<title>Description</title>
|
|
<methodsynopsis>
|
|
<type>int</type><methodname>getprotobyname</methodname>
|
|
<methodparam><type>string</type><parameter>name</parameter></methodparam>
|
|
</methodsynopsis>
|
|
<para>
|
|
<function>getprotobyname</function> returns the protocol number
|
|
associated with the protocol <parameter>name</parameter> as per
|
|
<filename>/etc/protocols</filename>.
|
|
</para>
|
|
<para>
|
|
See also: <function>getprotobynumber</function>.
|
|
</para>
|
|
</refsect1>
|
|
</refentry>
|
|
|
|
<refentry id="function.getprotobynumber">
|
|
<refnamediv>
|
|
<refname>getprotobynumber</refname>
|
|
<refpurpose>
|
|
Get protocol name associated with protocol number
|
|
</refpurpose>
|
|
</refnamediv>
|
|
<refsect1>
|
|
<title>Description</title>
|
|
<methodsynopsis>
|
|
<type>string</type><methodname>getprotobynumber</methodname>
|
|
<methodparam><type>int</type><parameter>number</parameter></methodparam>
|
|
</methodsynopsis>
|
|
<para>
|
|
<function>getprotobynumber</function> returns the protocol name
|
|
associated with protocol <parameter>number</parameter> as per
|
|
<filename>/etc/protocols</filename>.
|
|
</para>
|
|
<para>
|
|
See also: <function>getprotobyname</function>.
|
|
</para>
|
|
</refsect1>
|
|
</refentry>
|
|
|
|
<refentry id="function.getservbyname">
|
|
<refnamediv>
|
|
<refname>getservbyname</refname>
|
|
<refpurpose>
|
|
Get port number associated with an Internet service and protocol
|
|
</refpurpose>
|
|
</refnamediv>
|
|
<refsect1>
|
|
<title>Description</title>
|
|
<methodsynopsis>
|
|
<type>int</type><methodname>getservbyname</methodname>
|
|
<methodparam><type>string</type><parameter>service</parameter></methodparam>
|
|
<methodparam><type>string</type><parameter>protocol</parameter></methodparam>
|
|
</methodsynopsis>
|
|
<para>
|
|
<function>getservbyname</function> returns the Internet port
|
|
which corresponds to <parameter>service</parameter> for the
|
|
specified <parameter>protocol</parameter> as per
|
|
<filename>/etc/services</filename>.
|
|
<parameter>protocol</parameter> is either <literal>"tcp"</literal>
|
|
or <literal>"udp"</literal> (in lowercase).
|
|
</para>
|
|
<para>
|
|
See also: <function>getservbyport</function>.
|
|
</para>
|
|
</refsect1>
|
|
</refentry>
|
|
|
|
<refentry id="function.getservbyport">
|
|
<refnamediv>
|
|
<refname>getservbyport</refname>
|
|
<refpurpose>
|
|
Get Internet service which corresponds to port and protocol
|
|
</refpurpose>
|
|
</refnamediv>
|
|
<refsect1>
|
|
<title>Description</title>
|
|
<methodsynopsis>
|
|
<type>string</type><methodname>getservbyport</methodname>
|
|
<methodparam><type>int</type><parameter>port</parameter></methodparam>
|
|
<methodparam><type>string</type><parameter>protocol</parameter></methodparam>
|
|
</methodsynopsis>
|
|
<para>
|
|
<function>getservbyport</function> returns the Internet service
|
|
associated with <parameter>port</parameter> for the specified
|
|
<parameter>protocol</parameter> as per <filename>/etc/services</filename>.
|
|
<parameter>protocol</parameter> is either <literal>"tcp"</literal>
|
|
or <literal>"udp"</literal> (in lowercase).
|
|
</para>
|
|
<para>
|
|
See also: <function>getservbyname</function>.
|
|
</para>
|
|
</refsect1>
|
|
</refentry>
|
|
|
|
<refentry id="function.ip2long">
|
|
<refnamediv>
|
|
<refname>ip2long</refname>
|
|
<refpurpose>
|
|
Converts a string containing an (IPv4) Internet Protocol dotted address
|
|
into a proper address.
|
|
</refpurpose>
|
|
</refnamediv>
|
|
<refsect1>
|
|
<title>Description</title>
|
|
<methodsynopsis>
|
|
<type>int</type><methodname>ip2long</methodname>
|
|
<methodparam><type>string</type><parameter>ip_address</parameter></methodparam>
|
|
</methodsynopsis>
|
|
<para>
|
|
The function <function>ip2long</function> generates an IPv4 Internet
|
|
network address from its Internet standard format (dotted string)
|
|
representation.
|
|
<example>
|
|
<title><function>ip2long</function> Example</title>
|
|
<programlisting role="php">
|
|
<![CDATA[
|
|
<?php
|
|
$ip = gethostbyname("www.example.com");
|
|
$out = "The following URLs are equivalent:<br>\n";
|
|
$out .= "http://www.example.com/, http://".$ip."/, and http://".sprintf("%u",ip2long($ip))."/<br>\n";
|
|
echo $out;
|
|
?>
|
|
]]>
|
|
</programlisting>
|
|
</example>
|
|
<note>
|
|
<para>
|
|
Because PHP's integer type is signed, and many IP addresses will
|
|
result in negative integers, you need to use the "%u" formatter of
|
|
<function>sprintf</function> or <function>printf</function> to get
|
|
the string representation of the unsigned IP address.
|
|
</para>
|
|
</note>
|
|
This second example shows how to print a converted address with the
|
|
<function>printf</function> function :
|
|
<example>
|
|
<title>Displaying an IP address</title>
|
|
<programlisting role="php">
|
|
<![CDATA[
|
|
<?php
|
|
$ip = gethostbyname("www.example.com");
|
|
printf("%u\n", ip2long($ip));
|
|
echo $out;
|
|
?>
|
|
]]>
|
|
</programlisting>
|
|
</example>
|
|
</para>
|
|
<para>
|
|
See also: <function>long2ip</function>
|
|
</para>
|
|
</refsect1>
|
|
</refentry>
|
|
|
|
<refentry id="function.long2ip">
|
|
<refnamediv>
|
|
<refname>long2ip</refname>
|
|
<refpurpose>
|
|
Converts an (IPv4) Internet network address into a string in Internet
|
|
standard dotted format
|
|
</refpurpose>
|
|
</refnamediv>
|
|
<refsect1>
|
|
<title>Description</title>
|
|
<methodsynopsis>
|
|
<type>string</type><methodname>long2ip</methodname>
|
|
<methodparam><type>int</type><parameter>proper_address</parameter></methodparam>
|
|
</methodsynopsis>
|
|
<para>
|
|
The function <function>long2ip</function> generates an Internet address
|
|
in dotted format (i.e.: aaa.bbb.ccc.ddd) from the proper address
|
|
representation.
|
|
</para>
|
|
<para>
|
|
See also: <function>ip2long</function>
|
|
</para>
|
|
</refsect1>
|
|
</refentry>
|
|
|
|
<refentry id="function.openlog">
|
|
<refnamediv>
|
|
<refname>openlog</refname>
|
|
<refpurpose>Open connection to system logger</refpurpose>
|
|
</refnamediv>
|
|
<refsect1>
|
|
<title>Description</title>
|
|
<methodsynopsis>
|
|
<type>int</type><methodname>openlog</methodname>
|
|
<methodparam><type>string</type><parameter>ident</parameter></methodparam>
|
|
<methodparam><type>int</type><parameter>option</parameter></methodparam>
|
|
<methodparam><type>int</type><parameter>facility</parameter></methodparam>
|
|
</methodsynopsis>
|
|
<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 below.
|
|
The <parameter>option</parameter> argument is used to indicate
|
|
what loggin options will be used when generating a log message.
|
|
The <parameter>facility</parameter> argument is used to specify what
|
|
type of program is logging the message. This allows you to specify
|
|
(in your machine's syslog configuration) how messages coming from
|
|
different facilities will be handled.
|
|
The use of <function>openlog</function> is optional. It
|
|
will automatically be called by <function>syslog</function> if
|
|
necessary, in which case <parameter>ident</parameter> will default
|
|
to &false;.
|
|
</para>
|
|
<para>
|
|
<table>
|
|
<title><function>openlog</function> Options</title>
|
|
<tgroup cols="2">
|
|
<thead>
|
|
<row>
|
|
<entry>Constant</entry>
|
|
<entry>Description</entry>
|
|
</row>
|
|
</thead>
|
|
<tbody>
|
|
<row>
|
|
<entry>LOG_CONS</entry>
|
|
<entry>
|
|
if there is an error while sending data to the system logger,
|
|
write directly to the system console
|
|
</entry>
|
|
</row>
|
|
<row>
|
|
<entry>LOG_NDELAY</entry>
|
|
<entry>
|
|
open the connection to the logger immediately
|
|
</entry>
|
|
</row>
|
|
<row>
|
|
<entry>LOG_ODELAY</entry>
|
|
<entry>
|
|
(default) delay opening the connection until the first
|
|
message is logged
|
|
</entry>
|
|
</row>
|
|
<row>
|
|
<entry>LOG_PERROR</entry>
|
|
<entry>print log message also to standard error</entry>
|
|
</row>
|
|
<row>
|
|
<entry>LOG_PID</entry>
|
|
<entry>include PID with each message</entry>
|
|
</row>
|
|
</tbody>
|
|
</tgroup>
|
|
</table>
|
|
You can use one or more of this options. When using multiple options
|
|
you need to <literal>OR</literal> them, i.e. to open the connection
|
|
immediately, write to the console and include the PID in each message,
|
|
you will use: <literal>LOG_CONS | LOG_NDELAY | LOG_PID</literal>
|
|
</para>
|
|
<para>
|
|
<table>
|
|
<title><function>openlog</function> Facilities</title>
|
|
<tgroup cols="2">
|
|
<thead>
|
|
<row>
|
|
<entry>Constant</entry>
|
|
<entry>Description</entry>
|
|
</row>
|
|
</thead>
|
|
<tbody>
|
|
<row>
|
|
<entry>LOG_AUTH</entry>
|
|
<entry>
|
|
security/authorization messages (use LOG_AUTHPRIV instead
|
|
in systems where that constant is defined)
|
|
</entry>
|
|
</row>
|
|
<row>
|
|
<entry>LOG_AUTHPRIV</entry>
|
|
<entry>security/authorization messages (private)</entry>
|
|
</row>
|
|
<row>
|
|
<entry>LOG_CRON</entry>
|
|
<entry>clock daemon (cron and at)</entry>
|
|
</row>
|
|
<row>
|
|
<entry>LOG_DAEMON</entry>
|
|
<entry>other system daemons</entry>
|
|
</row>
|
|
<row>
|
|
<entry>LOG_KERN</entry>
|
|
<entry>kernel messages</entry>
|
|
</row>
|
|
<row>
|
|
<entry>LOG_LOCAL0 ... LOG_LOCAL7</entry>
|
|
<entry>reserved for local use</entry>
|
|
</row>
|
|
<row>
|
|
<entry>LOG_LPR</entry>
|
|
<entry>line printer subsystem</entry>
|
|
</row>
|
|
<row>
|
|
<entry>LOG_MAIL</entry>
|
|
<entry>mail subsystem</entry>
|
|
</row>
|
|
<row>
|
|
<entry>LOG_NEWS</entry>
|
|
<entry>USENET news subsystem</entry>
|
|
</row>
|
|
<row>
|
|
<entry>LOG_SYSLOG</entry>
|
|
<entry>messages generated internally by syslogd</entry>
|
|
</row>
|
|
<row>
|
|
<entry>LOG_USER</entry>
|
|
<entry>generic user-level messages</entry>
|
|
</row>
|
|
<row>
|
|
<entry>LOG_UUCP</entry>
|
|
<entry>UUCP subsystem</entry>
|
|
</row>
|
|
</tbody>
|
|
</tgroup>
|
|
</table>
|
|
</para>
|
|
<para>
|
|
See also <function>define_syslog_variables</function>,
|
|
<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>
|
|
<methodsynopsis>
|
|
<type>int</type><methodname>pfsockopen</methodname>
|
|
<methodparam><type>string</type><parameter>hostname</parameter></methodparam>
|
|
<methodparam><type>int</type><parameter>port</parameter></methodparam>
|
|
<methodparam choice="opt"><type>int</type><parameter>errno</parameter></methodparam>
|
|
<methodparam choice="opt"><type>string</type><parameter>errstr</parameter></methodparam>
|
|
<methodparam choice="opt"><type>int</type><parameter>timeout</parameter></methodparam>
|
|
</methodsynopsis>
|
|
<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.socket-get-status">
|
|
<refnamediv>
|
|
<refname>socket_get_status</refname>
|
|
<refpurpose>
|
|
Returns information about an existing socket stream
|
|
</refpurpose>
|
|
</refnamediv>
|
|
<refsect1>
|
|
<title>Description</title>
|
|
<methodsynopsis>
|
|
<type>array</type><methodname>socket_get_status</methodname>
|
|
<methodparam><type>resource</type><parameter>socketstream</parameter></methodparam>
|
|
</methodsynopsis>
|
|
<para>
|
|
Returns information about an existing socket stream. This function only
|
|
works on sockets created by <function>fsockopen</function>,
|
|
<function>pfsockopen</function> or network sockets returned by
|
|
<function>fopen</function> when opening URLs. It does NOT work
|
|
with sockets from the <link linkend="ref.sockets">Socket extension</link>.
|
|
Currently returns four entries in the result array:
|
|
</para>
|
|
<itemizedlist>
|
|
<listitem>
|
|
<para>
|
|
<parameter>timed_out</parameter> (bool) - The socket timed out
|
|
waiting for data
|
|
</para>
|
|
</listitem>
|
|
<listitem>
|
|
<para>
|
|
<parameter>blocked</parameter> (bool) - The socket was blocked
|
|
</para>
|
|
</listitem>
|
|
<listitem>
|
|
<para>
|
|
<parameter>eof</parameter> (bool) - Indicates EOF event
|
|
</para>
|
|
</listitem>
|
|
<listitem>
|
|
<para>
|
|
<parameter>unread_bytes</parameter> (int) - Number of bytes
|
|
left in the socket buffer
|
|
</para>
|
|
</listitem>
|
|
</itemizedlist>
|
|
<para>
|
|
See also: <link linkend="ref.sockets">Socket extension</link>.
|
|
</para>
|
|
</refsect1>
|
|
</refentry>
|
|
|
|
<refentry id="function.socket-set-blocking">
|
|
<refnamediv>
|
|
<refname>socket_set_blocking</refname>
|
|
<refpurpose>Set blocking/non-blocking mode on a socket</refpurpose>
|
|
</refnamediv>
|
|
<refsect1>
|
|
<title>Description</title>
|
|
<methodsynopsis>
|
|
<type>int</type><methodname>socket_set_blocking</methodname>
|
|
<methodparam><type>int</type><parameter>socket descriptor</parameter></methodparam>
|
|
<methodparam><type>int</type><parameter>mode</parameter></methodparam>
|
|
</methodsynopsis>
|
|
<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 <function>fgets</function> call will always
|
|
return right away while in blocking mode it will wait for data to
|
|
become available on the socket.
|
|
</para>
|
|
<para>
|
|
This function was previously called as
|
|
<function>set_socket_blocking</function> but this usage is deprecated.
|
|
</para>
|
|
</refsect1>
|
|
</refentry>
|
|
|
|
<refentry id="function.socket-set-timeout">
|
|
<refnamediv>
|
|
<refname>socket_set_timeout</refname>
|
|
<refpurpose>Set timeout period on a socket</refpurpose>
|
|
</refnamediv>
|
|
<refsect1>
|
|
<title>Description</title>
|
|
<methodsynopsis>
|
|
<type>bool</type><methodname>socket_set_timeout</methodname>
|
|
<methodparam><type>int</type><parameter>socket descriptor</parameter></methodparam>
|
|
<methodparam><type>int</type><parameter>seconds</parameter></methodparam>
|
|
<methodparam><type>int</type><parameter>microseconds</parameter></methodparam>
|
|
</methodsynopsis>
|
|
<para>
|
|
Sets the timeout value on <parameter>socket descriptor</parameter>,
|
|
expressed in the sum of <parameter>seconds</parameter> and
|
|
<parameter>microseconds</parameter>.
|
|
<example>
|
|
<title><function>socket_set_timeout</function> Example</title>
|
|
<programlisting role="php">
|
|
<![CDATA[
|
|
<?php
|
|
$fp = fsockopen("www.example.com", 80);
|
|
if(!$fp) {
|
|
echo "Unable to open\n";
|
|
} else {
|
|
fputs($fp,"GET / HTTP/1.0\n\n");
|
|
$start = time();
|
|
socket_set_timeout($fp, 2);
|
|
$res = fread($fp, 2000);
|
|
var_dump(socket_get_status($fp));
|
|
fclose($fp);
|
|
print $res;
|
|
}
|
|
?>
|
|
]]>
|
|
</programlisting>
|
|
</example>
|
|
</para>
|
|
<para>
|
|
This function was previously called as
|
|
<function>set_socket_timeout</function> but this usage is deprecated.
|
|
</para>
|
|
<para>
|
|
See also: <function>fsockopen</function> and <function>fopen</function>.
|
|
</para>
|
|
</refsect1>
|
|
</refentry>
|
|
|
|
<refentry id="function.syslog">
|
|
<refnamediv>
|
|
<refname>syslog</refname>
|
|
<refpurpose>Generate a system log message</refpurpose>
|
|
</refnamediv>
|
|
<refsect1>
|
|
<title>Description</title>
|
|
<methodsynopsis>
|
|
<type>int</type><methodname>syslog</methodname>
|
|
<methodparam><type>int</type><parameter>priority</parameter></methodparam>
|
|
<methodparam><type>string</type><parameter>message</parameter></methodparam>
|
|
</methodsynopsis>
|
|
<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>
|
|
<table>
|
|
<title><function>syslog</function> Priorities (in descending order)</title>
|
|
<tgroup cols="2">
|
|
<thead>
|
|
<row>
|
|
<entry>Constant</entry>
|
|
<entry>Description</entry>
|
|
</row>
|
|
</thead>
|
|
<tbody>
|
|
<row>
|
|
<entry>LOG_EMERG</entry>
|
|
<entry>system is unusable</entry>
|
|
</row>
|
|
<row>
|
|
<entry>LOG_ALERT</entry>
|
|
<entry>action must be taken immediately</entry>
|
|
</row>
|
|
<row>
|
|
<entry>LOG_CRIT</entry>
|
|
<entry>critical conditions</entry>
|
|
</row>
|
|
<row>
|
|
<entry>LOG_ERR</entry>
|
|
<entry>error conditions</entry>
|
|
</row>
|
|
<row>
|
|
<entry>LOG_WARNING</entry>
|
|
<entry>warning conditions</entry>
|
|
</row>
|
|
<row>
|
|
<entry>LOG_NOTICE</entry>
|
|
<entry>normal, but significant, condition</entry>
|
|
</row>
|
|
<row>
|
|
<entry>LOG_INFO</entry>
|
|
<entry>informational message</entry>
|
|
</row>
|
|
<row>
|
|
<entry>LOG_DEBUG</entry>
|
|
<entry>debug-level message</entry>
|
|
</row>
|
|
</tbody>
|
|
</tgroup>
|
|
</table>
|
|
</para>
|
|
<para>
|
|
<example>
|
|
<title>Using <function>syslog</function></title>
|
|
<programlisting role="php">
|
|
<![CDATA[
|
|
<?php
|
|
define_syslog_variables();
|
|
// open syslog, include the process ID and also send
|
|
// the log to standard error, and use a user defined
|
|
// logging mechanism
|
|
openlog("myScripLog", LOG_PID | LOG_PERROR, LOG_LOCAL0);
|
|
|
|
// some code
|
|
|
|
if (authorized_client()) {
|
|
// do something
|
|
} else {
|
|
// unauthorized client!
|
|
// log the attempt
|
|
$access = date("Y/m/d H:i:s");
|
|
syslog(LOG_WARNING,"Unauthorized client: $access $REMOTE_ADDR ($HTTP_USER_AGENT)");
|
|
}
|
|
|
|
closelog();
|
|
?>
|
|
]]>
|
|
</programlisting>
|
|
</example>
|
|
For information on setting up a user defined log handler, see the
|
|
<citerefentry><refentrytitle>syslog.conf</refentrytitle>
|
|
<manvolnum>5</manvolnum></citerefentry> Unix manual page. More
|
|
information on the syslog facilities and option can be found in the man
|
|
pages for <citerefentry><refentrytitle>syslog</refentrytitle>
|
|
<manvolnum>3</manvolnum></citerefentry> on Unix machines.
|
|
</para>
|
|
<para>
|
|
On Windows NT, the syslog service is emulated using the Event
|
|
Log.
|
|
</para>
|
|
<para>
|
|
See also <function>define_syslog_variables</function>,
|
|
<function>openlog</function> and
|
|
<function>closelog</function>.
|
|
</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
|
|
-->
|
|
|