listen
Table of Contents >> Programmer's Reference
| #include <trsocket.h> |
| int listen | ( |
| int socketDescriptor, | |
| int backLog | |
| ); |
Function Description
To accept connections, a socket is first created with socket(). A backlog for incoming connections is specified with listen() and then the connections are accepted with accept(). The listen() call applies only to sockets of type SOCK_STREAM. The backLog parameter defines the maximum length the queue of pending connections may grow to. If a connection request arrives with the queue full, and the underlying protocol supports retransmission, the connection request may be ignored so that retries may succeed. For AF_INET sockets, TCP will retry the connection. If the backlog is not cleared by the time the TCP times out, connect() will fail with TM_ETIMEDOUT.
Parameters
- socketDescriptor
- The socket descriptor to listen on.
- backLog
- The maximum number of outstanding connections allowed on the socket.
Return Values
- TM_ENOERROR
- Success
- TM_SOCKET_ERROR
- Failure
| TM_SOCKET_ERROR means that this socket call has failed and the errorCode has been set on the socket itself.
To retrieve the socket error the user must call tfGetSocketError(socketDescriptor). |
Possible socket errors
- TM_EADDRINUSE
- The address is currently used by another socket.
- TM_EBADF
- The socket descriptor is invalid.
- TM_EOPNOTSUPP
- The socket is not of a type that supports the listen() operation.