Compatibility: 6.8.1 Internet Commands or higher only
Platforms: Windows and Mac OS
TCP_Listen(remoteHost;localPort;remotePort;timeout;tcp_ID)
Under 4D Internet Commands 6.8.1 the command TCP_Listen has a new parameter behavior. In previous versions, if the variable remoteHost was left empty, it accepted an incoming connection from any machine. While this is still true under 6.8.1, in addition to this, the command will return into remoteHost the IP address of the connected machine.
Therefore it is now possible to filter the IP address of the remote host, making the process more efficient.
A quick example:
C_LONGINT(vTCPID)
C_INTEGER(vStatus)
C_TEXT(remoteHost)
remoteHost:=""
$err:=TCP_Listen (remoteHost;8000;8000;60;vTCPID)
$err:=TCP_State (vTCPID;vStatus)
If ((vStatus=8) & (remoteHost="10.96.0.63")) `connection was established and desired IP connected
`DoSomething
$err:=TCP_Close (vTCPID)
End if
For more information, please take a look at the 6.8.1 Internet Commands addendum pg. 58 TCP_Open under TCP Commands.