listen |
Prototype: |
#include <sys/socket.h>
#include <resolv.h>
int listen(int sockfd, int queue_len);
|
General Description: |
Convert the socket into a listening socket. This option is only available to SOCK_STREAM protocols. The call creates a queue of incoming connections. |
Return Value: |
Zero (0) if everything goes well. If an error occurs, you can find the cause in errno. |
Parameters |
sockfd |
A SOCK_STREAM socket which has been bound to a port. |
queue_len |
The maximum number of pending connections. |
Possible Errors |
EBADF |
The argument sockfd is not a valid descriptor. |
ENOTSOCK |
The argument sockfd is not a socket. |
EOPNOTSUPP |
The socket is not of a type that supports the listen() operation. If you supply any socket that is not SOCK_STREAM, you get this error. |
Examples |
int sockfd;
sockfd = socket(PF_INET, SOCK_STREAM, 0);
/*---set up address with bind()---*/
listen(sockfd, 10); /* create a 10-pending queue */
|