Hello
I am developing a client server problem and facing a problem.
I am running multiple clients from a single machine.Here, server accepts data from only one client and does not receive data from other clients while they are connected and sending data.
I am puzzled here why server is not receiving data from other clients.Can anybody help?
You might want to post some code.
However, let me take a guess simply from your description: you're not forking another process/generating another thread for an incoming client.
For each accept call, a thread is created to receive the data.
What I found is since I am running all the clients on same machine, same socket number is used for all the clients and if I disconnect one, all client gets disconnected.
This is because threads (and forked processes for that matter) inherit the file handles of their parents. The parent process should close the socket from the accept() call, and the child process should close the listen socket.
I take it this is a Windows app posted in the Unix section.
You're passing the address of the socket to the thread, but then overwritting that value each time accept() returns. So the socket used in the thread changes without the thread realising it. Why not pass it by value?
You shoud declare and initialise socket, clientAddressLen and clientAddres within the while loop.