I'm writing a P2P program in C++ such that the program is running in multiple hosts and each host is connected directly to each other (i.e. full graph).
My question is about the consideration that I should take into account when dealing with sockets in that case.
I need the communication to not a bottleneck and have really good time performance. Should I use separate thread for each connection? or some kind of infinite loop? what about accepting new connections? (i.e. accept()
). Doit make any difference whether it is under linux or Windows? What other matters should I consider?
I found several question deal with a subset of my problem, but they weren't fully addressed my concerns. (this and this for instance)