VARKON Version 1.17D 2003-03-25

| ## tcp_listen - function
Description
Listen on a specified TCP/IP socket port for an incomming connection, accepts the connection and provide the id of the established socket connection. The id is used for successive operatin (sending and receiving data). Always use TCP_close() to close the connection when session is over.
Syntax
tcp_listen(port, timeout, socket);
INT | port
FLOAT | timeout
INT | socket
Principal parameters
port | - Local port number to use for listen.
timeout | - Time to wait for incomming connection, if = 0 , no timeout (wait infinitely).
socket | - Integer to retrieve the id of the socket connection.
Optional parameters
none

Return value
An INT value equal to the current error status as below:

0 = | Operation was successful.
-1 = | Timeout value is expired.
-3 = | The network subsystem or the associated service provider has failed.
-4 = | Winsock routine WSAstartup() failed. Could not initiate the use of WS2_32.DLL.
-5 = | Winsock routine socket() failed. A socket could not be opened.
-6 = | Local address/port already in use.
-7 = | The local address/port is not valid.
-8 = | Winsock routine bind() failed. Could not bind to specified local port.
-13 = | The socket is already connected.
-14 = | Winsock routine listen() failed.
-15 = | Winsock routine select() failed (when listening).
-16 = | Winsock routine accept() failed.

Examples
`INT status; INT socket; status:= TCP_listen(5001, 60, socket);` We will listen for incomming atempts to connect on port 5001. The id of the socket connection will be stored in the variable 'socket'. If no connectoin is established within 60 seconds, the function will return with status = -1.

See also
tcp_connect() tcp_close() tcp_outint() tcp_inint() tcp_outfloat() tcp_infloat() tcp_outvec() tcp_invec() tcp_getlocal() tcp_getremote()

VARKON Homepage | Index