Quote:
Originally Posted by
Kam5FCC
Hi Corona,
Thanks for the reply.
What you are saying is correct if I was setting up a protocol and ack'ing all over the place. But what the boss wanted was a client that dumped off the data and left. Sooo....
TCP doesn't do that. The connecting process itself makes you wait.
Making your queue small will just prevent most of your clients from connecting at all when the server's busy, imagine russian roulette with 5/6 cylinders full.
Two ways to solve this.
1) Create threads to handle connections. The main program just does accept(); create_thread(); accept(); create_thread(); The threads do the communication. The clients won't have to wait for client1 to finish before they can connect. They might still wait a little just because connections take time to make -- you can't avoid that with TCP. And if the server's down, they'll wait an entire 10 minutes before giving up.
2) Use a connectionless protocol, probably UDP. Clients won't have to connect at all, just throwing a packet towards IP address 1.2.3.4 on port 5678 does the job. They won't even wait for the packet to get through, they won't even know if it gets through. The server can read and reply at its leisure.