Multiple TCP Clients

I am trying to create a sever program with multiple TCP clients on 9.21, the program needs to be able to handle commands from the clients as well as connection requests at any time. Is there a mechanism like a TCP interrupt where I could handle the TCP connection and command requests as they come in or do I have to loop and check for a connection request, then check each connection for a command.

One problem I discovered is that tcp_listen() when a function pointer is passed instead of NULL, the function will execute when the physical connection has been made not when data is sent as the description states.

Hi I have dun exactly what you are talking about and have tried several code models for the server.

  1. The big loop that listens for connection processes it and then closes the connection to do all over again. This assumes you need to send something for every received message.

  2. Another way would be to just listen for a connection and then create a task to carry out the command, allowing the listen code to go back to what it was doing.

  3. The final method I came up with is to separate the Incoming server messages and the processing of the commands to different tasks using a state machine to drive the hole mess.

This assumes you have a connection pool so you can co task a new iteration while the other one is working. The connection pool also allows you to look over the Connections on a timed interval and kill any died connections as well.

Though the third is probably the most complex and the first is the simplest. The second worked for my particular type of application. The other problem I ran into with this was the Co task model rabbit supplies with dynamic C. It was very problematic and most often ran over the stack with out even a squeak, and blew up the system I was testing on. I used this library “CoExec-DC” who only requires a fee when you use his code commercially.

Now for the reasons I am replying: The listener appears to listen even on local sends and I get a connection every time I send a message while my Listener is listening for new incoming connections. Has any one else ran into this problem?