I already tried the server prog but server can't distinguish between the clients please help me.
A client server program in which server counts the no of client's visited to the server. Server handles the multiple client at same time.
I already tried the server prog but server can't distinguish between the clients please help me.
A client server program in which server counts the no of client's visited to the server. Server handles the multiple client at same time.
A connection is always uniquely identified by two things: The "clients" address/port, and the "servers" address/port. The most common way to uniquely identify a client is to use its address/port pair.
Or if you just want to have a simple but unique small integer value, you can use the fact that the most common implementations use just a small integer value for the actual socket.
In C++ you could, for example, use a std::unordered_map
to store the data for each connection. Use the socket as the key, and a structure containing the needed data for the map data.
In C you most likely use a simple single-link list for the connection data, each structure containing the socket. To find the data corresponding to a specific socket just iterate over the list to find it.