Click here to Skip to main content
15,881,715 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
Hi,
I am building a little UDP server client app. in c++

In all the examples on the net that i saw, the server is 1st of all receives from the client and then sends
and the client 1st of all sends to the server and then receives from it.

I want the server to 1st of all send and the client to 1st of all receive.

The server will sends periodically a message and when the client is up it will receive it

Thanks!

dj

What I have tried:

I have built an echo server app. in which the server receives a message from a client a sends it back
Posted
Updated 1-Jul-19 0:33am

1 solution

The usual protocol is that the "master" sends first, and the slaves respond.

A slave never sends without being asked; it waits for a send request.

When the master starts, it polls available addresses (typically a subset within 1-31; 1-255; etc), with "address 0" for a general broadcast to all slaves listening.

Once the master builds its polling list, it send commands to individual slaves as required.
 
Share this answer
 
Comments
dj4400 2-Jul-19 10:59am    
Thanks Gerry for your answer
In my app. the server sends in broadcast a port number and now the client should send a response through this port

should the client close the broadcast socket and create a new one with the server address and new port or can it use the old socket in some way?

thanks!

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900