This content has been marked as final. Show 2 replies
Think about a very basic chat client-server application. Once a client connects, he receives all the messages entered by other clients. He can also send messages that will go to all the other clients. This is very much like your uncertainty about who will talk first, the server or the client. If the user/client waits a bit after connecting, it's likely the server will talk first (because another user sent a message). If the user/client is fast, he will speak first ("Hello everybody" or something like this). There are examples of such simple chat applications on the web, just google for them. And yes, this is typically achieved with endless loops. Each client will have such a loop attempting to read data from the server and the server will have as many endless loops concurrently (think multi-threading) active as there are clients connected.