-
Notifications
You must be signed in to change notification settings - Fork 14
Expand file tree
/
Copy pathsocket-strerror.xml
More file actions
83 lines (81 loc) · 2.84 KB
/
socket-strerror.xml
File metadata and controls
83 lines (81 loc) · 2.84 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
<?xml version="1.0" encoding="UTF-8"?>
<!-- splitted from ./it/functions/sockets.xml, last change in rev 1.4 -->
<!-- last change to 'socket-strerror' in en/ tree in rev 1.8 -->
<!-- EN-Revision: n/a Maintainer: darvina Status: ready -->
<!-- OLD-Revision: 1.34/EN.1.8 -->
<refentry xml:id="function.socket-strerror" xmlns="http://docbook.org/ns/docbook">
<refnamediv>
<refname>socket_strerror</refname>
<refpurpose>Restituisce una stringa con la descrizione dell'errore.</refpurpose>
</refnamediv>
<refsect1>
<title>Descrizione</title>
<methodsynopsis>
<type>string</type><methodname>socket_strerror</methodname>
<methodparam><type>int</type><parameter>errno</parameter></methodparam>
</methodsynopsis>
&warn.experimental.func;
<para>
La funzione <function>socket_strerror</function> utilizza come proprio
parametro <parameter>errno</parameter> il codice di errore di un socket fornito da
<function>socket_last_error</function> e restituisce il corrispondente testo
descrittivo. Questo rende più semplice piegare cosa è accaduto quando qualcosa
non funziona; ad esempio, invece di dovere cercare in tutto il
sistema un file che contenga la spiegazione di '-111', si può semplicemente
passare il valore a <function>socket_strerror</function>, e ottenere la
spiegazione di ciò che è accaduto.
</para>
<para>
<example>
<title>Esempio di uso di <function>socket_strerror</function></title>
<programlisting role="php">
<![CDATA[
<?php
if (false == ($socket = @socket_create (AF_INET, SOCK_STREAM, SOL_TCP))) {
echo "socket_create() fallito: motivo: " . socket_strerror (socket_last_error()) . "\n";
}
if (false == (@socket_bind ($socket, '127.0.0.1', 80))) {
echo "socket_bind() fallito: motivo: " . socket_strerror (socket_last_error($socket)) . "\n";
}
?>
]]>
</programlisting>
<para>
Dall'esempio precedente (se non viene eseguito con i
privilegi di root) ci si aspetta il seguente messaggio:
<screen>
socket_bind() fallito: motivo: Permission denied
</screen>
</para>
</example>
</para>
<para>
Vedere anche
<function>socket_accept</function>,
<function>socket_bind</function>,
<function>socket_connect</function>,
<function>socket_listen</function> e
<function>socket_create</function>.
</para>
</refsect1>
</refentry>
<!-- 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:"~/.phpdoc/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
-->