![]() |
|
| << Previous | Index | Next >> | |
| | |
int tcp_listen( tcp_Socket *s, word lport, longword remip,
word port, dataHandler_t datahandler, word reserved );Description
This function tells
DCRTCP.LIBthat an incoming session for a particular port will be accepted. After a call totcp_listen(), the functionsock_established()(or the macrosock_wait_established) must be called to poll the connection until a session is fully established.It is possible for a connection to be opened, written to and closed between two calls to the function
sock_established(). To handle this case, callsock_bytesready()to determine if there is data to be read from the buffer.Multiple calls to
tcp_listen()to the same local port (lport) are acceptable and constitute the mechanism for supporting multiple incoming connections to the same local port. Each time another host attempts to open a session on that particular port, another one of the listens will be consumed until such time as all listens have become established sessions and subsequent remote host attempts will receive a reset.Parameters
s
- Pointer to a socket.
lport
- Port to listen on (the local port number).
remip
- IP address of the remote host to accept connections from or 0 for all.
port
- Port to accept connections from or 0 for all.
datahandler
- Function to call when data is received;
NULLfor placing data in the socket's receive buffer. Prior to Dynamic C 7.30, some details for implementation of this service had not been finalized. Insert a value ofNULLif you are using a version of Dynamic C prior to 7.30.
reserved
- Set to 0 for now. This parameter is for compatibility and possible future use.
Return value
0: Failure.1: Success.Library
TCP.LIB (Prior to DC 7.05, this was DCRTCP.LIB)
See also
Example using tcp_listen()
| TCP/IP Manual Vol 1 |
<<Previous | Index | Next>> | rabbit.com |