First question: I would prefer to use one single process instead of two since data exchange would be simpler. Then choosing between a single thread solution (select()ing with no timeout from network and from user input in a loop) or a two threads solution I would probably stay for 2 threads, which is a little bit more complicated but more responsive to the user.
The rest of mechanism seems correct but may vary according to the implementation required by yor second question
Second question: I think that you always need to pass the hostname:port of at least one active client as argument.
I would develop this solution: if hostname:port are not passed then the client just does nothing (it's probably the first node of a network); if such info is present, then as first thing the client should try to connect to the given address.
The first contact should be followed by a special command that makes the contacted server to share info of every other active node in the network. In your case I would start P2P2 as "p2p Name_of_group Port_Number_for_Server_Side Port_Number_of_P2P1". Then
- P2P2 connects to P2P1 and ask for other nodes
- P2P1 answers that is is the only node
- now both P2P1 and P2P2 knows that the network is made of two nodes
Now you can start a P2P3 as "p2p Name_of_group Port_Number_for_Server_Side Port_Number_of_P2P1" or "p2p Name_of_group Port_Number_for_Server_Side Port_Number_of_P2P2". Let's assume you make it connect to P2P2
- P2P3 connects to P2P2 and asks for other active nodes
- P2P2 replies address info about P2P1
- P2P3 connects to P2P1 and do not ask for anything (or you can be redundant if you wish)