Listens for socket connections and limits the backlog of incoming connections.
#include <sys/types.h> #include <sys/socket.h> #include <netinet/in.h>
int listen (Socket, Backlog) int Socket, Backlog;
The listen subroutine performs the following activities:
The maximum queue length that the listen subroutine can specify is 10. The maximum queue length is indicated by the SOMAXCONN value in the /usr/include/sys/socket.h file.
Socket | Specifies the unique name for the socket. |
Backlog | Specifies the maximum number of outstanding connection requests. |
Upon successful completion, the listen subroutine returns a value 0.
If the listen subroutine is unsuccessful, the subroutine handler performs the following functions:
The subroutine is unsuccessful if any of the following errors occurs:
The following program fragment illustrates the use of the listen subroutine with 5 as the maximum number of outstanding connections which may be queued awaiting acceptance by the server process.
listen(s,5)
The listen subroutine is part of Base Operating System (BOS) Runtime.
All applications containing the listen subroutine must be compiled with _BSD set to a specific value. Acceptable values are 43 and 44. In addition, all socket applications must include the BSD libbsd.a library.
The accept subroutine, connect subroutine, socket subroutine.
Accepting Internet Stream Connections Example Program, Sockets Overview, Understanding Socket Connections in AIX Version 4.3 Communications Programming Concepts.