From 4382f9dcbe097b86c957ba028e2bcab6ca384f58 Mon Sep 17 00:00:00 2001 From: Sam Anthony Date: Sun, 1 Dec 2024 20:50:33 -0500 Subject: pass NetworkInterface to TotalOrderMulticastReceiver --- .../net/tomulticast/TotalOrderMulticastReceiver.java | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) (limited to 'src/main/java/derms/net/tomulticast/TotalOrderMulticastReceiver.java') diff --git a/src/main/java/derms/net/tomulticast/TotalOrderMulticastReceiver.java b/src/main/java/derms/net/tomulticast/TotalOrderMulticastReceiver.java index 549af16..bb0f2d8 100644 --- a/src/main/java/derms/net/tomulticast/TotalOrderMulticastReceiver.java +++ b/src/main/java/derms/net/tomulticast/TotalOrderMulticastReceiver.java @@ -6,6 +6,7 @@ import derms.util.ThreadPool; import java.io.IOException; import java.net.InetAddress; import java.net.InetSocketAddress; +import java.net.NetworkInterface; import java.time.Duration; import java.util.concurrent.*; import java.util.logging.Logger; @@ -24,6 +25,23 @@ public class TotalOrderMulticastReceiver { * * @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 TotalOrderMulticastReceiver(InetSocketAddress group, InetAddress laddr, NetworkInterface ifs) throws IOException { + this.deliver = new LinkedBlockingQueue>(); + this.log = Logger.getLogger(getClass().getName()); + + this.pool = Executors.newSingleThreadExecutor(); + this.receiver = new Receive(group, laddr, deliver, ifs); + pool.execute(receiver); + } + + /** + * Join the specified totally-ordered multicast group as a receiver using the + * default network interface of the machine. + * + * @param group The IP address and port of the multicast group. + * @param laddr The IP address of the local process. */ public TotalOrderMulticastReceiver(InetSocketAddress group, InetAddress laddr) throws IOException { this.deliver = new LinkedBlockingQueue>(); -- cgit v1.2.3