• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Tim Cooke
  • Campbell Ritchie
  • paul wheaton
  • Jeanne Boyarsky
  • Ron McLeod
Sheriffs:
  • Paul Clapham
  • Devaka Cooray
Saloon Keepers:
  • Tim Holloway
  • Carey Brown
  • Piet Souris
Bartenders:

Pinging a whole network and getting answers from listening servers

 
Greenhorn
Posts: 18
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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: https://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
 
Sheriff
Posts: 22841
132
Eclipse IDE Spring Chrome Java Windows
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
reply
    Bookmark Topic Watch Topic
  • New Topic