Places the specified socket in a state where it is listening for an incoming connection.
[ lReturn = ] WsListen ( socket )
The WsListen procedure syntax has the following parts:
Name |
Type |
Description |
lReturn |
Long |
Return code. Returns 0 is successful, -1 if failed. |
socket |
Val ASocket |
A handle identifying a bound, unconnected socket |
To accept connections, a socket is first created with the WsCreate function and bound to a local address with the WsBind function, a socket is then put into the WsListen mode by calling WsListen, and then the connections are accepted with the WsAccept function. Sockets that are connection oriented -- those of type TCP/IP -- are used with WsListen.
To prepare for a name association the TCP stream server must first listen for connection requests from the TCP client with the WsListen function.
! Open a socket:
lSocket1=WsCreate(aWsTcpIp,0)
! Associate a local host with a socket at a local port:
WsBind(lSocket1,lPort,lHost)
! Set the Socket to listen for an incoming connection from a client:
WsListen(lSocket1)
! Attempts to return a readwrite socket to the remote client in twenty seconds:
socketNew=WsAccept(socket,20000)