I am creating a simple chat program as my final project for a self taught c++ programming class.
Heres what i want to accomplish:
client: you type something in the client and push enter and it sends that to the server. the client also prints out anything the server echos back to the client.
server: the server accepts connections from the client(s) and then the server takes any text it gets from the clients and echos it back out to all the clients. Making a simple chat program.
This is a fairly simple process but im finding it fairly difficult to work with multiple clients.
What i need is help figuring out the process to do this. Here is my understanding of what should happen.
client / server:
make socket NON-blocking
bind to it
loop select and if read or write flags are triggured read or write
im not sure how the sockets work. i have a listens socket and i guess im suppost to make a new connection for every client but once my code gets past the accepting of the new clients and i go to write it just quits. and the write flag of select never even gets triggured. This is just something to think about, as soon as i get home ill post the actual code i have so far.
if you have any other ideas for how i could accomplish this please post (besides using fork etc)