lundi 30 juillet 2018

C++ multi chat server

i am trying to write a multi chat server without using threads. I came across select() but i am having hard time understanding how can i read a client request and send it right away when the send() blocks and the client socket might not be ready to be wriiten and by this losing the server parallel io ability.

If(fd_isset(socket,&read_fds){
    Recv()
    SendMesgToRequestedClient()
}

I thought a possible soulution is to save each client a list of pending messages and send them on fd_isset(socket,&write_fds) but then instand of saving cpu i might use a ton of memory.

Aucun commentaire:

Enregistrer un commentaire