I am working on a server/client chat system.
I want to add a feature to the server so that when the client sends "/list\n" to the server,
the server will send all the names of the users currently logged in, together with the total number of the logged-in users.
So, I send the usernames like this from the server:
Code:
for (j=0; j<k; j++) {
write(csock[i],user[j],sizeof(user[j]));
write(csock[i],"\n",1);
}
where user[j] stores the username.
So, how can I send the number of the logged-in users, k, to the socket so that the client can get it? btw, k is an integer.
Thanks.