I am making a multiplayer networking game. Now to connect to the server, client needs the ip address of the server.
So, the way I implement this is as follows.
Client Broadcasts its ip address at Broadcast IP and a port say A. Server listens to it over A, and
Server creates a new UDP connection with the client behaving as a client say over port B. It sends all the important information required for the game including its IP.
Client is the server for this connection and receives the data from server over port B.
Now, A and B are constants. So when I need the server to listen for multiple clients in different threads I can put diff values to A and B for the threads but in the client file A and B are independent of these threads. So it gives me an error of
bind: Address already in use
What is the plausible solution for this?