Reputation: 94
Im new to either boost and asio (but not to network programming) and Im currently trying to create a TCP server accepting multiple clients. The primary functionnality of the server with clients is simple :
1- Read a Header with a fixed size;
2- Interpret what kind of request it is, read the rest of the packet;
3- Handle request with all the data;
4- Going back to step 1.
This is working with basic requests like : Checking Credentials, Enabling a FTP protocol, etc... But there is a problem : One request demands to communicate with another connected client through the server. But, if I follow the Boost Asio architecture given in this example of the Boost website
Or the one in this conference
I don't actually have access to the other clients socket, they are not stocked, they live thanks to the behaviour of smart pointers.
I indeed have a solution for this problem, its to keep the connected sockets in list, and to share it with every connected socket, so at every time the client can access to other clients socket. But I really think that this is not a good architecure, and that it could be better.
Is there any known way to resolve this problem ?
Upvotes: 2
Views: 544
Reputation: 21416
Here is a good approach:
This way only the server keeps the sockets. And all clients uses IDs to identify one another.
Upvotes: 1