Hi All,
I am implementing a kind of IP finder for a particular type of network multimedia device. I want to find out all the alive devices of that type in the LAN, with their IP address and other details.
The device has its own way of device discovery.
It works as follows:
A client sends a broadcast request over the LAN via UDP.
The destination port number is fixed.
In reply, all the servers in the LAN that understand the format of this request will respond to this request providing information about themselves.
I am broadcasting the UDP request message using sendto().
Now my problem is that I don't know how many devices (i.e.servers) will respond to the request.
How many times will I have to call recvfrom()?
When will I come to know that I have handled the response from all the devices?
Or in general, is recvfrom() the right choice for receiving response from multiple servers?
Is there any better (or CORRECT if I am wrong here) way of accomplishing the same?
I am programming in C/C++, planning to code for both Windows and Linux.
Many thanks in advance.
Edit:
So with the help of all the network programming wizards out here, I have found the solution to my problem :)
select() is just the thing for me...
Thanks a lot to all of you who took out time to help me