Finding the multicast IP that a datagram was sent to

In my application I have one MulticastSocket that joins 40 multicast IP addresses (On the same port).

When receiving a datagram, is there a way to find the specific Multicast IP that a it was sent to ?

The same question about the new "DatagramChannel" (in Java 7), that also support multicasting.

Thank you very much !

-------------Problems Reply------------

In Java 1 through 6 you must create one socket per IP multicast address and then use private data to help determine the incoming address.

In the host CRT you can use IP_PKTINFO and the CMSG_* apis to determine the destination address but these have not been exposed in Java.

Java 7 brings NIO support for multicast along with SSM (RFC3768).

Category:java Views:0 Time:2011-08-05
Tags: java multicast

Related post

  • Uses of SO_REUSEADDR? 2009-02-23

    I have used SO_REUSEADDR to have my server which got terminated to restart with out complaining that the socket is already is in use. I was wondering if there are other uses of SO_REUSEADDR? Have anyone used the socket option for other than the said

  • Network Discovery via datagram sockets: Multicasting 2011-12-09

    I'm implementing the example where a server listens for any active clients in the network. I'm using Datagram sockets for the server to do the multicast and clients to respon to the server. public void run() { try { byte[] recvBuf = new byte[15000];

  • Setting the UDP datagram source on a multicast join 2012-02-15

    I have a windows XP machine having a single network adapter with 2 IP addresses (basically there are 2 subnets on the same physical network): IP Address 1: mask IP address 2: mask Default Gateway:

  • Throttling multicast datagrams 2009-11-23

    I have an application that is sending some UDP packets using multicast. I looked at the network traffic and there seems to be a lot of ancillary packets related to using multicast. I don't totally understand it, but does multicast by nature result in

  • Send and receive IPv6 link-local multicast UDP datagrams in Python? 2010-07-06

    This following is a straightforward IPv4 UDP broadcast, followed by listening on all interfaces. sock = socket.socket(socket.AF_INET, socket.SOCK_DGRAM) sock.setsockopt(socket.SOL_SOCKET, socket.SO_BROADCAST, True) sock.bind(("", 1337)) sock.sendto("

  • Java Multicast Time To Live is always 0 2008-09-26

    I have a problem with setting the TTL on my Datagram packets. I am calling the setTTL(...) method on the packet before sending the packet to the multicastSocket but if I capture the packet with ethereal the TTL field is always set to 0 --------------

  • Why UDP socket subscribed to a multicast group is picking up a non-multicast message? 2009-07-21

    Overview: I have set up a server and a client, where both attempt discovery of each other using UDP. When the server starts up it sends a multicast message ( that it is alive. When the client starts up it sends a multicast message (239.1.1.

  • UDP Server Discovery - Should clients send multicasts to find server or should server send regular beacon? 2009-07-30

    I have clients that need to all connect to a single server process. I am using UDP discovery for the clients to find the server. I have the client and server exchange IP address and port number, so that a TCP/IP connection can be established after co

  • IPv6 multicast addressing: Are all "Group IDs" considered valid/user-assignable? 2009-09-22

    I'm seeing some "interesting" behavior in my program's link-local IPv6 multicast routines. It seems that if I set any of the upper 16 bits of the 112-bit Group ID field, then MacOS/X will no longer accept those multicast packets. My question is, is t

  • Determine the remaining TTL of a multicast packet in Java 2009-11-12

    If I have a Java program that listens to multicast data, how can I tell what the remaining TTL of the incoming datagram is? I know how to set the TTL on the sending multicast socket, but I want to know the remaining TTL of the arriving packet. ------

  • Is Multicast broken for Android 2.0.1 (currently on the DROID) or am I missing something? 2010-03-10

    This code works perfectly in Ubuntu, Windows, and Mac OS X. It also works fine with a Nexus One running Android 2.1.1. I start sending and listening multicast datagrams, and all the computers and the Nexus One will see each other perfectly. Then I ru

  • From a Java programming perspective, what difference does multicast make to a networking program? 2010-06-17

    My manager has asked me to assess what changes would be required to add multicast support to a socket-based TCP/IP networking program that is part of a trading system. As far as I can tell, from the perspective of a Java program, it doesn't seem to m

  • What possible uses would multicast support have in a Java trading system? 2010-06-17

    I've been asked to look into adding multicast support to a Java trading system but, to be honest, I don't have the slightest clue what this could be for. Would this mainly be to allow the trading system to broadcast trade messages to different types

  • Unix Domain Socket: Using datagram communication between one server process and several client processes 2010-07-24

    I would like to establish an IPC connection between several processes on Linux. I have never used UNIX sockets before, and thus I don't know if this is the correct approach to this problem. One process receives data (unformated, binary) and shall dis

  • Datagram coming from the "wrong" IP 2010-09-07

    I have a Linux box with a virtual IP set up. Here's part of the output from ip addr: 2: eth0: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc pfifo_fast qlen 1000 link/ether e4:1f:13:60:10:34 brd ff:ff:ff:ff:ff:ff inet brd 2

  • What's the difference between a "stream-type" socket and a "datagram" socket type? 2010-10-23

    What's the difference between a "stream-type" socket and a "datagram" socket type? --------------Solutions------------- The short answer: message boundaries and connections. With a stream socket you can write two five byte messages and wind up readin

  • IPv6 Multicast Check Java 2010-11-12

    Is there any better to way to check if I can receive a given IP Multicast transmission. Following code works fine but there is a problem in this code - it blocks the current thread until it gets the multicast packets. Thank you. import

  • Selectable Multicast socket (pre 1.7) 2010-11-18

    With the advent of NIO most socket types could be "selectable" through the SelectableChannel implementation. Unfortunately the DatagramChannel does not support multicast prior to java 7. Multicast is supported in prior versions via the MulticastSocke

  • Why use Unicast versus Multicast in Weblogic Clusters 2010-12-02

    It's unclear from the documentation why you should use Unicast rather than Multicast in a WebLogic cluster. Anyone have experience using either and the benefits of moving to Unicast? --------------Solutions------------- The main difference between Un

Copyright (C), All Rights Reserved.

processed in 0.158 (s). 11 q(s)