HTTP Interfacing and ports

I did some testing on listening for TCP connections and here is what I found works:

Start by calling Listen for Incoming Communication. This opens up the port and can be a different comm handle than the one you use for Accept Incoming Communication - which is useful if you want to handle more than one client (one comm handle per client).

If the port opens okay then loop on Accept Incoming Communication. The command will time out every ~10 seconds with -442 if a client doesn’t connect and you have to call it again. If it has an error other than -442, you will most likely need to go back to Listen for Incoming Communication to reopen the port. As mentioned above, you can use a different comm handle if you want to communicate with multiple clients simultaneously. I have more information on that if you need it.

Now that you have a client connected, you can loop on Get Number of Characters Waiting until you see some data. If the socket goes down (negative result from the call), then you want to go back to calling Accept Incoming Communication until the client connects again.

1 Like