Command group | Flag affected | Reversible | Execute on client | Platform(s) |
---|---|---|---|---|
External commands | YES | NO | NO | All |
TCPListen (socket) Returns status
Note: The flag is set according to whether Omnis was able to make a call to this external command.
This Web command is multi-threaded, allowing another thread to execute in the multi-threaded server while it runs. Note that the same socket cannot safely be used concurrently by more than one thread.
TCPListen puts a socket created with TCPSocket into listening mode. When a socket is in listening mode, it will acknowledge incoming connection requests addressed to the port bound to the socket, and place them in a queue, ready to be accepted using TCPAccept.
Socket is an Omnis Long Integer field containing the number of a socket that has been bound to a port.
Status is an Omnis Long Integer field which receives the value zero for success, or an error code < 0 for failure. Possible error codes are listed in the Web Command Error Codes Appendix.
# Listen for a incoming connections on port iPort
Calculate iPort as 6000
TCPSocket Returns iSocket
TCPBind (iSocket,iPort) Returns lStatus
TCPListen (iSocket) Returns lStatus
If lStatus=0
Repeat
TCPAccept (iSocket) Returns lConnectedSocket
Until lConnectedSocket>=0
# client connected
End If
TCPClose (iSocket) Returns lStatus