summaryrefslogtreecommitdiffstats
path: root/src/main/java/derms/net/rmulticast/ReliableMulticast.java
diff options
context:
space:
mode:
authorSam Anthony <sam@samanthony.xyz>2024-12-01 13:08:59 -0500
committerSam Anthony <sam@samanthony.xyz>2024-12-01 13:08:59 -0500
commit773c4b8a696dd49b3f0452783e1634350a82226a (patch)
treeef12f77af9c8f6fd1ba80cd58bb2e811bbc2e978 /src/main/java/derms/net/rmulticast/ReliableMulticast.java
parentfc28d5d3607ac5056272e61b272a823c25dc9bc1 (diff)
downloadsoen423-773c4b8a696dd49b3f0452783e1634350a82226a.zip
pass network interface name to sequencer explicitely
Diffstat (limited to 'src/main/java/derms/net/rmulticast/ReliableMulticast.java')
-rw-r--r--src/main/java/derms/net/rmulticast/ReliableMulticast.java15
1 files changed, 13 insertions, 2 deletions
diff --git a/src/main/java/derms/net/rmulticast/ReliableMulticast.java b/src/main/java/derms/net/rmulticast/ReliableMulticast.java
index f3db55c..c08d5a1 100644
--- a/src/main/java/derms/net/rmulticast/ReliableMulticast.java
+++ b/src/main/java/derms/net/rmulticast/ReliableMulticast.java
@@ -38,8 +38,9 @@ public class ReliableMulticast<T extends MessagePayload> {
*
* @param group The IP address and port of the multicast group.
* @param laddr The IP address of the local process.
+ * @param ifs The network interface to use.
*/
- public ReliableMulticast(InetSocketAddress group, InetAddress laddr) throws IOException {
+ public ReliableMulticast(InetSocketAddress group, InetAddress laddr, NetworkInterface ifs) throws IOException {
this.group = group;
this.laddr = laddr;
@@ -49,7 +50,7 @@ public class ReliableMulticast<T extends MessagePayload> {
this.retransmissions = new LinkedBlockingQueue<Message<T>>();
this.groupMembers = ConcurrentHashMap.newKeySet();
- NetworkInterface ifs = Net.getMulticastInterface();
+ System.out.println(getClass().getSimpleName() + " using network interface " + ifs);
this.sock = DatagramChannel.open(StandardProtocolFamily.INET)
.setOption(StandardSocketOptions.SO_REUSEADDR, true)
.bind(new InetSocketAddress(group.getAddress(), group.getPort()))
@@ -67,6 +68,16 @@ public class ReliableMulticast<T extends MessagePayload> {
pool.execute(new Heartbeat(group, laddr, acks, nacks, sock));
}
+ /**
+ * Join the specified multicast group using the default network interface on the machine.
+ *
+ * @param group The IP address and port of the multicast group.
+ * @param laddr The IP address of the local process.
+ */
+ public ReliableMulticast(InetSocketAddress group, InetAddress laddr) throws IOException {
+ this(group, laddr, Net.getMulticastInterface());
+ }
+
public void close() throws IOException {
log.info("Shutting down...");
sock.close();