Log In    |    Knowledge Base    |    4D Home
Tech Tip: Using the TCP_listen command in a loop
PRODUCT: 4D Internet Commands | VERSION: 2004.2 | PLATFORM: Mac & Win
Published On: November 4, 2005

You can pass a null string ("") to accept incoming connection from any machine or a variable containing a null string as remote host parameter for the TCP_Listen command. If you use a variable, it will return the IP address of the connected machine. In this case, if you execute the said command in a loop, the next time the command is executed, the variable will now have the IP address of the connected machine and the command could return an error. So if you want to remain to listen for incoming connection from any machine, you can either pass a null string ("") or reinitialize the variable back to a null string before using it again in the loop. For example in code below, the variable is initialized to null whenever the command is executed:



  $err:=TCP_Listen (RemoteHost;0;RemotePort;30;v_ SessionID)


Until(($err #0) | (Status=0))