I'm trying to design a C++ chat application. I'd like it to be able to cope with any number of users (it's a theoretical problem), no matter how big this number might be.

I've been reading documentation about sockets, and, even if there are some socket based chat applications, I'm not sure of neither whether this is the best approach nor whether sockets would make my system collapse if an enormous amount of users tried to use the chat at once.

As far as I understand it, for each connecting socket a new port has to be opened. And in case the chat application allowed private conversations, it wouldn't be possible to repeat a port number, even in different processes, let alone threads... So, if I'm taking the wrong way and someone can clearly explain me why, and, even better, to hint me another option, I'd be most grateful.