Win a copy of Re-engineering Legacy Software this week in the Refactoring forum
or Docker in Action in the Cloud/Virtualization forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Pinging a whole network and getting answers from listening servers

 
Andreas Pax Lück
Greenhorn
Posts: 18
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi friends!

I searched the internet about my problem, but didn't really find satisfying answers. This thread seemed to be interesting: http://www.coderanch.com/t/209321/Distributed-Java/java/there-any-method-get-address

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?


Best regards


PAX
 
Rob Spoor
Sheriff
Pie
Posts: 20495
54
Chrome Eclipse IDE Java Windows
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Perhaps DatagramSockets are what you need. These allow you to multicast messages.
 
Andreas Pax Lück
Greenhorn
Posts: 18
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Rob.

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.

Do you know what's wrong with my solution?

Best regards


PAX
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic