This week's book giveaway is in the OCAJP 8 forum. We're giving away four copies of OCA Java SE 8 Programmer I Study Guide and have Edward Finegan & Robert Liguori on-line! See this thread for details.
I have to develop a kind of server application which does listen, among other things, for ping requests and answer to the specific machine. This client machine doesn't know the IP address. So I tried to ping to 255.255.255.255 but this IP was rejected. Is there any way to send a request to all participants without the knowledge of their IPs?
"Wenn man irgendwann mal von allen akzeptiert wird, dann weiß man, dass man irgendwas falsch gemacht hat." Excerpt by: Mr. Weidner
Thanks for your answer. I'd like to excuse my belated reply, I was a bit busy in the previous weeks.
I informed me about this multicast communication. The key note is that this connectionless kind of communication provides the possiblity that participants join any group and every message which is sent to this group will be obtained by every group member. A group is defined by a class D network IP address.
I think, this approach would solve my concern. But I've got a question: The group is defined by a class D address. If another (further) application uses the same IP in any way, does my application produce any conflicts?
I implemented a ping prototype which does only work localy. This means, if the client and the server are running on the same machine, the ping request arrives the server. But if there's a further server on the network running on another machine, no ping comes in.
This is the client's ping:
And here's the server:
As already mentioned, it does only work if server and client are running on the same computer. The computers are connected via a router on my network. The client code for the listening to answers isn't shown in the code above. First, it starts the listener in a separate thread and then it sends the ping.