| Command group | Flag affected | Reversible | Execute on client | Platform(s) |
| External commands | YES | NO | NO | All |
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.
TCPSocket creates a new socket. The only use of such a socket is to bind a port to it using TCPBind, start listening on the port using TCPListen, and then accept incoming connections using TCPAccept.
Socket is an Omnis Long Integer field which receives the number of the allocated socket. If an error occurs, the command returns a negative number.
# Create a new socket, bind it to port 6000 and listen for a incoming# client connection
CalculateiPortas6000TCPSocketReturnsiSocket
TCPBind(iSocket,iPort)ReturnslStatus
TCPListen(iSocket)ReturnslStatus
IflStatus=0RepeatTCPAccept(iSocket)ReturnslConnectedSocketUntillConnectedSocket>=0# client connected
End If
TCPClose(iSocket)ReturnslStatus