From 4d84a123056497f6658f849264ed46d6555285fd Mon Sep 17 00:00:00 2001 From: Jason Greene Date: Fri, 29 Nov 2002 23:57:20 +0000 Subject: [PATCH] Start of the sockets documentation make-over Describe in detail all possible options to socket_create() without the need to refer to other documentation. git-svn-id: https://svn.php.net/repository/phpdoc/en/trunk@106231 c90b9560-bf6c-de11-be94-00142212c4b1 --- reference/sockets/functions/socket-create.xml | 174 ++++++++++++++---- 1 file changed, 141 insertions(+), 33 deletions(-) diff --git a/reference/sockets/functions/socket-create.xml b/reference/sockets/functions/socket-create.xml index b2826dc869..91b0f7c83b 100644 --- a/reference/sockets/functions/socket-create.xml +++ b/reference/sockets/functions/socket-create.xml @@ -1,5 +1,5 @@ - + @@ -14,47 +14,155 @@ inttype intprotocol - &warn.experimental.func; - Creates a communication endpoint (a socket), and returns a socket - resource. + 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. - The domain parameter sets the domain (protocol - family) to be used for communication. Currently, - AF_INET and AF_UNIX are - understood. AF_INET is typical used for internet - based communication. AF_UNIX uses pathnames to - identify sockets and can therefore only be used for local communication - (which is faster, on the other hand). + The domain parameter specifies the protocol + family to be used by the socket. + + Available address/protocol families + + + + Domain + Description + + + + + AF_INET + + IPv4 Internet based protocols. TCP and UDP are common protocols of + this protocol family. + + + + AF_UNIX + + Local communication protocol family. High efficiency and low + overhead make it a great form of IPC (Interprocess Communication). + + + + +
- The type parameter selects the socket - type. This is one of SOCK_STREAM, - SOCK_DGRAM, - SOCK_SEQPACKET, - SOCK_RAW, SOCK_RDM, or - SOCK_PACKET. The two most common types are - SOCK_DGRAM for UDP - (connectionless) communication - and SOCK_STREAM for TCP - communication. + The type parameter selects the type of communication + to be used by the socket. + + Available socket types + + + + Type + Description + + + + + SOCK_STREAM + + 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. + + + + SOCK_DGRAM + + Supports datagrams (connectionless, unreliable messages of a fixed maximum length). + The UDP protocol is based on this socket type. + + + + SOCK_SEQPACKET + + 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. + + + + SOCK_RAW + + 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). + + + + SOCK_RDM + + Provides a reliable datagram layer that does not guarantee ordering. + This is most likely not implemented on your operating system. + + + + +
- protocol sets the protocol which is either - SOL_UDP or SOL_TCP. + The protocol parameter sets the specific + protocol within the specified domain to be used + when communicating on the returned socket. The proper value can be retrieved by + name by using getprotobyname. If + the desired protocol is TCP, or UDP the corresponding constants + SOL_TCP, and SOL_UDP + can also be used. + + Common protocols + + + + Name + Description + + + + + icmp + + 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. + + + + udp + + 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. + + + + tcp + + 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. + + + + +
- Returns a socket resource on success, or &false; on error. The actual - error code can be retrieved by calling - socket_last_error. This error code may be passed to - socket_strerror to get a textual explanation of the - error. - - - For more information on the usage of socket_create, - as well as on the meanings of the various parameters, see the - Unix man page socket (2). + socket_create Returns a socket resource on success, or &false; + on error. The actual error code can be retrieved by calling socket_last_error. + This error code may be passed to socket_strerror to get a textual + explanation of the error.