string compare function...

Need c++ string compare function...
Last edited on
The client looks ok, if a little odd. But I can see you needed to read from the socket and stdin, so you created a thread.

The server has real problems, I think it got away from you a bit. The structure should be something:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
main thread:
    initialise response info
    initialise socket
    while new connection
        create worker thread to handle connection
exit

worker thread:
    add name to roster
    while new command
        process command
    remove name from roster
    close socket
exit


You should make up a data structure that has all your tokens/answers and let the threads read from it concurrently.

Get rid of that array of connections, users join and leave asynchronously, so you can't track them that way. Instead, let each thread handle a socket, and at the start, let them register the connected users name in a global roster and remove it on leaving. Access to this roster must be synchronised.
Last edited on
Topic archived. No new replies allowed.