Linux and UNIX Man Pages

Linux & Unix Commands - Search Man Pages

listen(2) [hpux man page]

listen(2)							System Calls Manual							 listen(2)

NAME
listen - listen for connections on a socket SYNOPSIS
DESCRIPTION
To accept connections, a socket is first created using a queue for incoming connections is activated using and then connections are accepted using applies only to unconnected sockets of type SOCK_STREAM. Except for AF_VME_LINK, if the socket has not been bound to a local port before is invoked, the system automatically binds a local port for the socket to listen on (see inet(7F)). For sockets in the address family AF_CCITT and AF_VME_LINK, the socket be bound to an address by using before connection establishment can continue, otherwise an error is returned. A listen queue is established for the socket specified by the s parameter, which is a socket descriptor. backlog defines the desirable queue length for pending connections. The actual queue length may be greater than the specified backlog. If a connection request arrives when the queue is full, the client will receive an error. backlog is limited to the range of 0 to which is defined in is currently set to 4096. If any other value is specified, the system automat- ically assigns the closest value within the range. Note that for a backlog of 0 specifies only 1 pending connection is allowed at any given time. For a backlog of 0 specifies no further connection is allowed. X/Open Sockets Compilation Environment See xopen_networking(7). DEPENDENCIES
AF_CCITT Call-acceptance can be controlled by the call described in Upon successful completion, returns 0; otherwise, it returns -1 and sets to indicate the error. ERRORS
fails if any of the following conditions are encountered: s is not a valid file descriptor. The socket s has not been bound to an address by using s is a valid file descriptor but it is not a socket. The socket referenced by s does not support The socket has been shut down or is already connected. WARNINGS
Linking binary objects compiled to specification and binary objects compiled to specification to the same executable may result in unex- pected behavior, including application abnormal termination and unexpected socket errors. See xopen_networking(7) for details and remedy. FUTURE DIRECTION
Currently, the default behavior is the however, it might be changed to in a future release. At that time, any behavior that is incompati- ble with might be obsoleted. Applications that conform to the X/Open specification now will avoid migration problems (see xopen_network- ing(7)). AUTHOR
was developed by HP and the University of California, Berkeley. SEE ALSO
accept(2), connect(2), socket(2), thread_safety(5), xopen_networking(7), inet(7F). STANDARDS CONFORMANCE
listen(2)

Check Out this Related Man Page

accept(2)							System Calls Manual							 accept(2)

NAME
accept - accept a connection on a socket SYNOPSIS
AF_CCITT only UNIX 03 only (X/Open Sockets) Obsolescent UNIX 95 only (X/Open Sockets) DESCRIPTION
The system call is used with connection-based socket types, such as The argument, s, is a socket descriptor created with bound to a local address by and listening for connections after a extracts the first connection on the queue of pending connections, creates a new socket with the same properties as s, and returns a new file descriptor, ns, for the socket. If no pending connections are present on the queue and nonblocking mode has not been enabled with the or flags or the request, blocks the caller until a connection is present. and are defined in (see fcntl(2), fcntl(5), and socket(7)). and the equivalent request are defined in although use of is not recommended (see ioctl(2), ioctl(5), and socket(7)). If the socket has nonblocking mode enabled and no pending connections are present on the queue, returns an error as described below. The accepted socket, ns, cannot be used to accept more connections. The original socket s remains open for incoming connection requests. To determine whether a listening socket has pending connection requests ready for an call, use for reading. The argument addr should point to a socket address structure. The call fills in this structure with the address of the connecting entity, as known to the underlying protocol. In the case of AF_UNIX sockets, the peer's address is filled in only if the peer had done an explicit before doing a Therefore, for AF_UNIX sockets, in the common case, when the peer had not done an explicit before doing a the structure is filled with a string of nulls for the address. The format of the address depends upon the protocol and the address-family of the socket s. The argument addrlen is a pointer to a variable. Initially, the variable should contain the size of the structure pointed to by addr. On return, it contains the actual length (in bytes) of the address returned. If the memory pointed to by addr is not large enough to contain the entire address, only the first addrlen bytes of the address are returned. If addr is NULL or addrlen contains 0, the connecting entity's address will not be returned. The and flags and request are all supported. These features interact as follows: o If the or flag has been set, requests behave accordingly, regardless of any requests. o If neither the flag nor the flag has been set, requests control the behavior of AF_CCITT only The addr parameter to returns addressing information for the connecting entity, except for the field of addr which contains the name of the local X.25 interface through which the connection request arrived. Call-acceptance can be controlled with the request. X/Open Sockets Compilation Environment See xopen_networking(7). RETURN VALUE
Upon successful completion, returns a nonnegative integer which is a descriptor for the accepted socket. If an error occurs, returns and sets to indicate the cause. ERRORS
If fails, is set to one of the following values: Nonblocking I/O is enabled using and no connections are present to be accepted. The argument, s, is not a valid file descriptor. The socket is being shutdown due to a request by software. This is usually caused by a system call. The addr parameter is not a valid pointer. The call was interrupted by a signal before a valid connection arrived. The socket referenced by s is not currently a listen socket or has been shut down with A must be done before an is allowed. The maximum number of file descriptors for this process are currently open. The system's table of open files is full and no more calls can be processed at this time. No buffer space is available. The cannot complete. The queued socket connect request is aborted. No memory is available. The cannot complete. The queued socket connect request is aborted. The argument, s, is a valid file descriptor, but it is not a socket. The socket referenced by s does not support Nonblocking I/O is enabled using or and no connections are present to be accepted. OBSOLESCENCE
Currently, the and types are the same size. This is compatible with the UNIX 95 and UNIX 03 profiles. However, in a future release, might be a different size. In that case, passing a pointer will evoke compile-time warnings, which must be corrected in order for the applica- tion to behave correctly. Applications that use now, where appropriate, will avoid such migration problems. On the other hand, applica- tions that need to be portable to the UNIX 95 profile should follow the X/Open specification (see xopen_networking(7)). WARNINGS
Linking binary objects compiled to specification and binary objects compiled to specification to the same executable may result in unex- pected behavior, including application abnormal termination and unexpected socket errors. See xopen_networking(7) for details and remedy. FUTURE DIRECTION
Currently, the default behavior is the however, it might be changed to in a future release. At that time, any behavior that is incompati- ble with might be obsoleted. Applications that conform to the X/Open specification now will avoid migration problems (see xopen_network- ing(7)). AUTHOR
was developed by HP and the University of California, Berkeley. SEE ALSO
bind(2), connect(2), listen(2), select(2), socket(2), privileges(5), thread_safety(5), xopen_networking(7). STANDARDS CONFORMANCE
accept(2)
Man Page