Command group | Flag affected | Reversible | Execute on client | Platform(s) |
---|---|---|---|---|
External commands | YES | NO | NO | All |
TCPGetRemoteAddr (socket) Returns address
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.
TCPGetRemoteAddr returns the IP address of the remote computer to which a given socket is connected.
Socket is an Omnis Long Integer field containing a connected socket.
Address is an Omnis Character field which receives the IP Address of the host to which the socket is connected. The IP address is of the form 255.255.255.254
Possible error codes are listed in the Web Command Error Codes Appendix.
# Listen for a incoming connections on port iPort and get the IP
# address iAddress of the remote computer
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
TCPGetRemoteAddr (lConnectedSocket) Returns iAddress
End If
TCPClose (iSocket) Returns lStatus