Sophie

Sophie

distrib > PLD > ac > amd64 > media > dist > by-pkgid > dd8ef74e7a184506d40e4328053fb785 > files > 3048

php-manual-ro-20051028-1.noarch.rpm

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<HTML
><HEAD
><TITLE
>socket_create</TITLE
><META
NAME="GENERATOR"
CONTENT="Modular DocBook HTML Stylesheet Version 1.7"><LINK
REL="HOME"
TITLE="Manual PHP"
HREF="index.html"><LINK
REL="UP"
TITLE="Socket Functions"
HREF="ref.sockets.html"><LINK
REL="PREVIOUS"
TITLE="socket_create_pair"
HREF="function.socket-create-pair.html"><LINK
REL="NEXT"
TITLE="socket_get_option"
HREF="function.socket-get-option.html"><META
HTTP-EQUIV="Content-type"
CONTENT="text/html; charset=ISO-8859-2"></HEAD
><BODY
CLASS="refentry"
BGCOLOR="#FFFFFF"
TEXT="#000000"
LINK="#0000FF"
VLINK="#840084"
ALINK="#0000FF"
><DIV
CLASS="NAVHEADER"
><TABLE
SUMMARY="Header navigation table"
WIDTH="100%"
BORDER="0"
CELLPADDING="0"
CELLSPACING="0"
><TR
><TH
COLSPAN="3"
ALIGN="center"
>Manual PHP</TH
></TR
><TR
><TD
WIDTH="10%"
ALIGN="left"
VALIGN="bottom"
><A
HREF="function.socket-create-pair.html"
ACCESSKEY="P"
>Înapoi</A
></TD
><TD
WIDTH="80%"
ALIGN="center"
VALIGN="bottom"
></TD
><TD
WIDTH="10%"
ALIGN="right"
VALIGN="bottom"
><A
HREF="function.socket-get-option.html"
ACCESSKEY="N"
>Înainte</A
></TD
></TR
></TABLE
><HR
ALIGN="LEFT"
WIDTH="100%"></DIV
><H1
><A
NAME="function.socket-create"
></A
>socket_create</H1
><DIV
CLASS="refnamediv"
><A
NAME="AEN108550"
></A
><P
>    (PHP 4 &#62;= 4.1.0, PHP 5)</P
>socket_create&nbsp;--&nbsp;Create a socket (endpoint for communication)</DIV
><DIV
CLASS="refsect1"
><A
NAME="AEN108553"
></A
><H2
>Description</H2
>resource <B
CLASS="methodname"
>socket_create</B
> ( int domain, int type, int protocol)<BR
></BR
><P
>&#13;     Creates and returns a socket resource, also referred to as an endpoint
     of communication. A typical network connection is made up of 2 sockets, one
     performing the role of the client, and another performing the role of the server.
    </P
><P
>&#13;     The <VAR
CLASS="parameter"
>domain</VAR
> parameter specifies the protocol
     family to be used by the socket.
    </P
><DIV
CLASS="table"
><A
NAME="AEN108570"
></A
><P
><B
>Tabel 1. Available address/protocol families</B
></P
><TABLE
BORDER="1"
CLASS="CALSTABLE"
><COL><COL><THEAD
><TR
><TH
>Domain</TH
><TH
>Description</TH
></TR
></THEAD
><TBODY
><TR
><TD
>AF_INET</TD
><TD
>&#13;        IPv4 Internet based protocols. TCP and UDP are common protocols of 
        this protocol family.
       </TD
></TR
><TR
><TD
>AF_INET6</TD
><TD
>&#13;        IPv6 Internet based protocols. TCP and UDP are common protocols of 
        this protocol family. Support added in <VAR
CLASS="literal"
>PHP 5.0.0</VAR
>.
       </TD
></TR
><TR
><TD
>AF_UNIX</TD
><TD
>&#13;        Local communication protocol family. High efficiency and low
        overhead make it a great form of IPC (Interprocess Communication).
       </TD
></TR
></TBODY
></TABLE
></DIV
><P
>&#13;     The <VAR
CLASS="parameter"
>type</VAR
> parameter selects the type of communication
     to be used by the socket.
    </P
><DIV
CLASS="table"
><A
NAME="AEN108590"
></A
><P
><B
>Tabel 2. Available socket types</B
></P
><TABLE
BORDER="1"
CLASS="CALSTABLE"
><COL><COL><THEAD
><TR
><TH
>Type</TH
><TH
>Description</TH
></TR
></THEAD
><TBODY
><TR
><TD
>SOCK_STREAM</TD
><TD
>&#13;         Provides sequenced, reliable, full-duplex, connection-based byte streams.  
         An out-of-band data transmission mechanism may be supported.
         The TCP protocol is based on this socket type.
       </TD
></TR
><TR
><TD
>SOCK_DGRAM</TD
><TD
>&#13;         Supports datagrams (connectionless, unreliable messages of a fixed maximum length).
         The UDP protocol is based on this socket type.
       </TD
></TR
><TR
><TD
>SOCK_SEQPACKET</TD
><TD
>&#13;         Provides a sequenced, reliable, two-way connection-based data transmission path for 
         datagrams of fixed maximum length;  a consumer is required to read an
         entire packet with each read call. 
       </TD
></TR
><TR
><TD
>SOCK_RAW</TD
><TD
>&#13;         Provides raw network protocol access. This special type of socket
         can be used to manually construct any type of protocol. A common use
         for this socket type is to perform ICMP requests (like ping,
         traceroute, etc).
       </TD
></TR
><TR
><TD
>SOCK_RDM</TD
><TD
>&#13;         Provides a reliable datagram layer that does not guarantee ordering. 
         This is most likely not implemented on your operating system.
       </TD
></TR
></TBODY
></TABLE
></DIV
><P
>&#13;     The <VAR
CLASS="parameter"
>protocol</VAR
> parameter sets the specific
     protocol within the specified <VAR
CLASS="parameter"
>domain</VAR
> to be used
     when communicating on the returned socket. The proper value can be retrieved by 
     name by using <A
HREF="function.getprotobyname.html"
><B
CLASS="function"
>getprotobyname()</B
></A
>. If 
     the desired protocol is TCP, or UDP the corresponding constants 
     <TT
CLASS="constant"
><B
>SOL_TCP</B
></TT
>, and <TT
CLASS="constant"
><B
>SOL_UDP</B
></TT
> 
     can also be used.
    </P
><DIV
CLASS="table"
><A
NAME="AEN108619"
></A
><P
><B
>Tabel 3. Common protocols</B
></P
><TABLE
BORDER="1"
CLASS="CALSTABLE"
><COL><COL><THEAD
><TR
><TH
>Name</TH
><TH
>Description</TH
></TR
></THEAD
><TBODY
><TR
><TD
>icmp</TD
><TD
>&#13;        The Internet Control Message Protocol is used primarily by gateways
        and hosts to report errors in datagram communication. The "ping"
        command (present in most modern operating systems) is an example 
        application of ICMP.
       </TD
></TR
><TR
><TD
>udp</TD
><TD
>&#13;        The User Datagram Protocol is a connectionless, unreliable,
        protocol with fixed record lengths. Due to these aspects, UDP 
        requires a minimum amount of protocol overhead.
       </TD
></TR
><TR
><TD
>tcp</TD
><TD
>&#13;        The Transmission Control Protocol is a reliable, connection based, 
        stream oriented, full duplex protocol. TCP guarantees that all data packets 
        will be received in the order in which they were sent. If any packet is somehow
        lost during communication, TCP will automatically retransmit the packet until
        the destination host acknowledges that packet. For reliability and performance 
        reasons, the TCP implementation itself decides the appropriate octet boundaries 
        of the underlying datagram communication layer. Therefore, TCP applications must 
        allow for the possibility of partial record transmission.
       </TD
></TR
></TBODY
></TABLE
></DIV
><P
>&#13;     <B
CLASS="function"
>socket_create()</B
> Returns a socket resource on success, or <TT
CLASS="constant"
><B
>FALSE</B
></TT
> 
     on error. The actual error code can be retrieved by calling <A
HREF="function.socket-last-error.html"
><B
CLASS="function"
>socket_last_error()</B
></A
>.
     This error code may be passed to <A
HREF="function.socket-strerror.html"
><B
CLASS="function"
>socket_strerror()</B
></A
> to get a textual 
     explanation of the error.
    </P
><DIV
CLASS="note"
><BLOCKQUOTE
CLASS="note"
><P
><B
>Not&#227;: </B
>
      If an invalid <VAR
CLASS="parameter"
>domain</VAR
> or
      <VAR
CLASS="parameter"
>type</VAR
> is given, <B
CLASS="function"
>socket_create()</B
>
      defaults to <TT
CLASS="constant"
><B
>AF_INET</B
></TT
> and
      <TT
CLASS="constant"
><B
>SOCK_STREAM</B
></TT
> respectively and additionally emits an
      <TT
CLASS="constant"
><B
>E_WARNING</B
></TT
> message.
     </P
></BLOCKQUOTE
></DIV
><P
>&#13;     See also 
     <A
HREF="function.socket-accept.html"
><B
CLASS="function"
>socket_accept()</B
></A
>,
     <A
HREF="function.socket-bind.html"
><B
CLASS="function"
>socket_bind()</B
></A
>,
     <A
HREF="function.socket-connect.html"
><B
CLASS="function"
>socket_connect()</B
></A
>,
     <A
HREF="function.socket-listen.html"
><B
CLASS="function"
>socket_listen()</B
></A
>,
     <A
HREF="function.socket-last-error.html"
><B
CLASS="function"
>socket_last_error()</B
></A
>, and
     <A
HREF="function.socket-strerror.html"
><B
CLASS="function"
>socket_strerror()</B
></A
>.
    </P
></DIV
><DIV
CLASS="NAVFOOTER"
><HR
ALIGN="LEFT"
WIDTH="100%"><TABLE
SUMMARY="Footer navigation table"
WIDTH="100%"
BORDER="0"
CELLPADDING="0"
CELLSPACING="0"
><TR
><TD
WIDTH="33%"
ALIGN="left"
VALIGN="top"
><A
HREF="function.socket-create-pair.html"
ACCESSKEY="P"
>Înapoi</A
></TD
><TD
WIDTH="34%"
ALIGN="center"
VALIGN="top"
><A
HREF="index.html"
ACCESSKEY="H"
>Acas&#227;</A
></TD
><TD
WIDTH="33%"
ALIGN="right"
VALIGN="top"
><A
HREF="function.socket-get-option.html"
ACCESSKEY="N"
>Înainte</A
></TD
></TR
><TR
><TD
WIDTH="33%"
ALIGN="left"
VALIGN="top"
>socket_create_pair</TD
><TD
WIDTH="34%"
ALIGN="center"
VALIGN="top"
><A
HREF="ref.sockets.html"
ACCESSKEY="U"
>Sus</A
></TD
><TD
WIDTH="33%"
ALIGN="right"
VALIGN="top"
>socket_get_option</TD
></TR
></TABLE
></DIV
></BODY
></HTML
>