diff --git a/reference/sockets/functions/socket-accept.xml b/reference/sockets/functions/socket-accept.xml index 438fedf91d..7945b3acc9 100644 --- a/reference/sockets/functions/socket-accept.xml +++ b/reference/sockets/functions/socket-accept.xml @@ -1,5 +1,5 @@ - + @@ -9,36 +9,36 @@ Description - intsocket_accept + resourcesocket_accept resourcesocket - &warn.experimental.func; + &warn.experimental.func; After the socket socket has been created using socket_create, bound to a name with socket_bind, and told to listen for connections with socket_listen, this function will accept incoming connections on that socket. Once a successful connection - is made, a new socket descriptor is returned, which may be used + is made, a new socket resource is returned, which may be used for communication. If there are multiple connections queued on the socket, the first will be used. If there are no pending connections, socket_accept will block until a connection becomes present. If socket has been made non-blocking using socket_set_blocking or - socket_set_nonblock, an error code will be - returned. + socket_set_nonblock, &false; will be returned. - The socket descriptor returned by + The socket resource returned by socket_accept may not be used to accept new connections. The original listening socket socket, however, remains open and may be reused. - Returns a new socket descriptor on success, or a negative error - code on failure. This code may be passed to + Returns a new 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. diff --git a/reference/sockets/functions/socket-create.xml b/reference/sockets/functions/socket-create.xml index 55fe13569e..b2826dc869 100644 --- a/reference/sockets/functions/socket-create.xml +++ b/reference/sockets/functions/socket-create.xml @@ -1,5 +1,5 @@ - + @@ -16,13 +16,17 @@ &warn.experimental.func; - Creates a communication endpoint (a socket), and returns a - descriptor to the socket. + Creates a communication endpoint (a socket), and returns a socket + resource. - The domain parameter sets the - domain. Currently, AF_INET and - AF_UNIX are understood. + 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 type parameter selects the socket @@ -30,14 +34,20 @@ SOCK_DGRAM, SOCK_SEQPACKET, SOCK_RAW, SOCK_RDM, or - SOCK_PACKET. + SOCK_PACKET. The two most common types are + SOCK_DGRAM for UDP + (connectionless) communication + and SOCK_STREAM for TCP + communication. - protocol sets the protocol. + protocol sets the protocol which is either + SOL_UDP or SOL_TCP. - Returns a valid socket descriptor on success, or a negative error - code on failure. This code may be passed to + 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. @@ -46,12 +56,22 @@ as well as on the meanings of the various parameters, see the Unix man page socket (2). + + + If an invalid domain or + type is given, socket_create + defaults to AF_INET and + SOCK_STREAM respectively and additionally emits an + E_WARNING message. + + See also socket_accept, socket_bind, socket_connect, - socket_listen, and + socket_listen, + socket_last_error, and socket_strerror.