This is my problem statement:
A multi threaded server sends out periodic message “any clients there”. Client machines need to respond with message just to prove that clients do exist on a particular IP.
Doubts:
Is this how I should proceed?
- Client sends out a multicast message.
2.Assuming that the client machine has no client is not listening on a particular port i.e. no program is running on the client, how do I do it? - If 2 is not possible, how do I know that there are clients on my network(without a program running on the client)? Please don’t suggest ZeroConf as I can’t get crossed over ethernet cables here.
In fact, I’m curious how a simple network discovery program can list all the other computers on the network without any program running on the client. Should I use Java Ping()?
The easiest way (since Java 5) to find out if a particular client exists is to use the
isReachable()method on InetAddress, which pretty much does everything for you (you just need to specify a timeout.) The javadoc link above gives some insight into how it works. This gives some alternatives if you’re pre-Java 5 (or just want to implement your own thing.)For multiple clients, have a look here which shows how to broadcast on the server side to a particular group.