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

  • SEARCH
  • Home
  • 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 4106320
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 20, 20262026-05-20T21:21:41+00:00 2026-05-20T21:21:41+00:00

I have a very similar behaviour as described here : running on a Mac

  • 0

I have a very similar behaviour as described here:

  • running on a Mac Book Pro, Snow Leopard
  • using Multicast Sockets to send and receive packets on localhost

I’m using Eclipse and observed the following behaviour when the client / server are started from within the workspace:

  • if the wireless interface (airport) is up and running, the client does not receive any packets
  • if the interface is turned off, everything works as expected

But what I don’t understand is:

  • if I create a JAR and run the code in any console -> all good! Just Eclipse seems not to like airport 😉
  • depending on what wireless network I’m connected to, the above behaviour might change, i.e. it also works if airport is enabled (for example @ Uni)

Does anyone have an idea ’bout this?

Cheers

Below the straightforward code for server / client:

@Override
public void run() {
    String multicastAddress = "224.0.0.2";
    int multicastPort = 8000;
    MulticastSocket socket = null;
    try {
        try {
            InetAddress multicastGoup = InetAddress.getByName(multicastAddress);
            socket = new MulticastSocket(multicastPort);
            socket.joinGroup(multicastGoup);
        } catch (IOException e) {
            e.printStackTrace();
            return;
        }
        byte[] buffer = new byte[1024];

        while (true) {
            DatagramPacket packet = new DatagramPacket(buffer, buffer.length);

            System.out.println("BEFORE RECEIVE: listening on " + multicastAddress + ":" + multicastPort);
            socket.receive(packet);
            System.out.println("PACKET RECEIVED");

            System.err.println("Client received: " + new String(packet.getData()));
        }

    } catch (UnknownHostException e) {
        e.printStackTrace();
    } catch (IOException e) {
        e.printStackTrace();
    } catch (Exception e) {
        e.printStackTrace();
    } finally {
        socket.close();
    }

}

Server:

    public void run() {
    MulticastSocket socket = null;
    try {
        String multicastAddress = "224.0.0.2";
        int multicastPort = 8000;
        InetAddress multicastGoup = InetAddress.getByName(multicastAddress );
        socket = new MulticastSocket(multicastPort);
        socket.joinGroup(multicastGoup);

        byte[] data = new String("Teststring").getBytes();

        while (true) {
            socket.send(new DatagramPacket(data, data.length, multicastGoup, multicastPort));
            System.out.println("SERVER: Datagram sent");
            Thread.sleep(1000);
        }

    } catch (IOException e) {
        e.printStackTrace();
    } catch (Exception e) {
        e.printStackTrace();
    } finally {
        socket.close();
    }
}
  • 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-05-20T21:21:42+00:00Added an answer on May 20, 2026 at 9:21 pm

    From Class MulticastSocket:

    void  joinGroup(SocketAddress mcastaddr, NetworkInterface netIf)
              Joins the specified multicast group at the specified interface.
    

    Try using a specific interface so your joinGroup doesn’t fall into the default – which may vary according on available, open ones or due to Eclipse settings.

    joinGroup
    
    public void joinGroup(SocketAddress mcastaddr,
                          NetworkInterface netIf)
                   throws IOException
    
      Joins the specified multicast group at the specified interface.
    
      If there is a security manager, this method first calls its
      checkMulticast method with the mcastaddr argument as its argument.
    
      Parameters:
        mcastaddr - is the multicast address to join
        netIf - specifies the local interface to receive
            multicast datagram packets,
          -- here is the catch
          or null to defer to the interface set by
            setInterface(InetAddress) or 
            setNetworkInterface(NetworkInterface) 
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

i am running into a similar issue as described here: Java Linux Nonblocking Socket
(There is a very similar topic that never got solved: here ) We have
I am working with data.frames that have very similar names (df1, df2,.. df7). Because
I have a very similar situation to the person who asked: Can I serve
I have two very similar programs each trying to run two threads OddThread and
I have something very similar to this example: https://developers.google.com/maps/documentation/javascript/examples/directions-simple All I am trying to
I was looking at this post: https://stackoverflow.com/a/2262200 and I have a very similar setup
I know that this is a repeated question. I have found very similar questions
I have a couple very similar looking folders on my machine that correspond to
I have very simple OpenGL ES example similar to Hehe's example : http://nehe.gamedev.net/tutorial/ios_lesson_02__first_triangle/50001/ As

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.