Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 9011003
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 16, 20262026-06-16T02:36:49+00:00 2026-06-16T02:36:49+00:00

MulticastSocket multicast_socket = new MulticastSocket(Dialogos.MULTICAST_PORTA); InetAddress group = InetAddress.getByName(Dialogos.MULTICAST_IP_GRUPO); multicast_socket.joinGroup(group); byte[] msg = new

  • 0
MulticastSocket multicast_socket = new MulticastSocket(Dialogos.MULTICAST_PORTA);
InetAddress group = InetAddress.getByName(Dialogos.MULTICAST_IP_GRUPO);
multicast_socket.joinGroup(group);
byte[] msg = new byte[1024];
DatagramPacket packet = new DatagramPacket(msg, msg.length);
multicast_socket.receive(packet);

In the code above, the server is receiving a request from a client, via multicast. The server is now supposed to let the client know “where” it is. This is just one method for the client to guess where to connect, it’s not completely dependent on it.

The server can be installed on many different environments though, so I don’t know which interface/address will be used to communicate with the client. Therefore, to tell the client where it is, I’m compiling all the available ip addresses in the server and sending them all back in a multicast, so that the client can try them out until one succeeds.

My question: Is there a way to improve this mechanism? I wonder if, on the server app, I could get the local ip that received the multicast from the client, then I’d know which one to send back. Can’t find methods that do that though. Maybe some way to attempt a connection to the client just to know which local address it would pick to do so?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-16T02:36:50+00:00Added an answer on June 16, 2026 at 2:36 am

    Just send unicast UDP packet back to the client, and the client will be able to extract the source IP address. That will ensure it’s the address on the interface/route where client and server can talk to each other. You will need that packet to tell the listening port number somehow, of course.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm trying to execute a simple example of Multicast sockets on Java. MulticastSocket s
I have two threads. First one sends datagrams with a MulticastSocket in loop; the
Ok, I'm fairly new to C sockets but I just need to do some
I'm developing an Android 3.1 Tablet application. It has a MulticastSocket : public MulticastClient(String
I am using MulticastSocket to receive UDP Multicast packets. How can I determine to
I made a little chat applet using multicast. It works fine between computers on
I have limited Java Socket experience and all of it using TCP. I am
I'm trying to send a long over a multicast. The connection should work, because
Ok, if you look at some of my previous questions, I've been working on
I have some code that listens for announcements via UDP multicast. I can get

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.