Linux and UNIX Man Pages

Linux & Unix Commands - Search Man Pages

listen(3socket) [opensolaris man page]

listen(3SOCKET) 					     Sockets Library Functions						   listen(3SOCKET)

NAME
listen - listen for connections on a socket SYNOPSIS
cc [ flag ... ] file ... -lsocket -lnsl [ library ... ] #include <sys/types.h> #include <sys/socket.h> int listen(int s, int backlog); DESCRIPTION
To accept connections, a socket is first created with socket(3SOCKET), a backlog for incoming connections is specified with listen() and then the connections are accepted with accept(3SOCKET). The listen() call applies only to sockets of type SOCK_STREAM or SOCK_SEQPACKET. The backlog parameter defines the maximum length the queue of pending connections may grow to. If a connection request arrives with the queue full, the client will receive an error with an indication of ECONNREFUSED for AF_UNIX sock- ets. If the underlying protocol supports retransmission, the connection request may be ignored so that retries may succeed. For AF_INET and AF_INET6sockets, the TCP will retry the connection. If the backlog is not cleared by the time the tcp times out, the connect will fail with ETIMEDOUT. RETURN VALUES
A 0 return value indicates success; -1 indicates an error. ERRORS
The call fails if: EBADF The argument s is not a valid file descriptor. ENOTSOCK The argument s is not a socket. EOPNOTSUPP The socket is not of a type that supports the operation listen(). ATTRIBUTES
See attributes(5) for descriptions of the following attributes: +-----------------------------+-----------------------------+ | ATTRIBUTE TYPE | ATTRIBUTE VALUE | +-----------------------------+-----------------------------+ |MT-Level |Safe | +-----------------------------+-----------------------------+ SEE ALSO
accept(3SOCKET), connect(3SOCKET), socket(3SOCKET), attributes(5), socket.h(3HEAD) NOTES
There is currently no backlog limit. SunOS 5.11 8 Nov 1999 listen(3SOCKET)

Check Out this Related Man Page

accept(3SOCKET) 					     Sockets Library Functions						   accept(3SOCKET)

NAME
accept - accept a connection on a socket SYNOPSIS
cc [ flag ... ] file ... -lsocket -lnsl [ library ... ] #include <sys/types.h> #include <sys/socket.h> int accept(int s, struct sockaddr *addr, socklen_t *addrlen); DESCRIPTION
The argument s is a socket that has been created with socket(3SOCKET) and bound to an address with bind(3SOCKET), and that is listening for connections after a call to listen(3SOCKET). The accept() function extracts the first connection on the queue of pending connections, cre- ates a new socket with the properties of s, and allocates a new file descriptor, ns, for the socket. If no pending connections are present on the queue and the socket is not marked as non-blocking, accept() blocks the caller until a connection is present. If the socket is marked as non-blocking and no pending connections are present on the queue, accept() returns an error as described below. The accept() function uses the netconfig(4) file to determine the STREAMS device file name associated with s. This is the device on which the connect indication will be accepted. The accepted socket, ns, is used to read and write data to and from the socket that connected to ns. It is not used to accept more connections. The original socket (s) remains open for accepting further connections. The argument addr is a result parameter that is filled in with the address of the connecting entity as it is known to the communications layer. The exact format of the addr parameter is determined by the domain in which the communication occurs. The argument addrlen is a value-result parameter. Initially, it contains the amount of space pointed to by addr; on return it contains the length in bytes of the address returned. The accept() function is used with connection-based socket types, currently with SOCK_STREAM. It is possible to select(3C) or poll(2) a socket for the purpose of an accept() by selecting or polling it for a read. However, this will only indicate when a connect indication is pending; it is still necessary to call accept(). RETURN VALUES
The accept() function returns -1 on error. If it succeeds, it returns a non-negative integer that is a descriptor for the accepted socket. ERRORS
accept() will fail if: EBADF The descriptor is invalid. ECONNABORTED The remote side aborted the connection before the accept() operation completed. EFAULT The addr parameter or the addrlen parameter is invalid. EINTR The accept() attempt was interrupted by the delivery of a signal. EMFILE The per-process descriptor table is full. ENODEV The protocol family and type corresponding to s could not be found in the netconfig file. ENOMEM There was insufficient user memory available to complete the operation. ENOSR There were insufficient STREAMS resources available to complete the operation. ENOTSOCK The descriptor does not reference a socket. EOPNOTSUPP The referenced socket is not of type SOCK_STREAM. EPROTO A protocol error has occurred; for example, the STREAMS protocol stack has not been initialized or the connection has already been released. EWOULDBLOCK The socket is marked as non-blocking and no connections are present to be accepted. ATTRIBUTES
See attributes(5) for descriptions of the following attributes: +-----------------------------+-----------------------------+ | ATTRIBUTE TYPE | ATTRIBUTE VALUE | +-----------------------------+-----------------------------+ |MT-Level |Safe | +-----------------------------+-----------------------------+ SEE ALSO
poll(2), bind(3SOCKET), connect(3SOCKET), listen(3SOCKET), select(3C), socket.h(3HEAD), socket(3SOCKET), netconfig(4), attributes(5) SunOS 5.11 24 Jan 2002 accept(3SOCKET)
Man Page