Answer the question
In order to leave comments, you need to log in
How on the client, using a broadcast request, find the server (Winsock)?
There is a server on the PC, I immediately launch the client (All via UDP). How to make a broadcast request to find the server, get its ip (well, here 127.0.0.1 and it will be in any case I think) and port to fill in the structure:
RecvAddr.sin_family = AF_INET;
RecvAddr.sin_port = htons(Port);
RecvAddr.sin_addr.s_addr = inet_addr("127.0.0.1");
Answer the question
In order to leave comments, you need to log in
The client sends a broadcast (SO_BROADCAST) packet "Server, ay!" to the broadcast address of the network.
The server, having received such a request, sends directly to the client the packet "Ayushki?"
The client, having received such a response from the server, remembers the sender's address.
If several servers answered, then the client chooses the one he likes.
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question