summaryrefslogtreecommitdiffstats
path: root/src/main/java/derms/net/tomulticast/TotalOrderMulticastReceiver.java
diff options
context:
space:
mode:
authorSam Anthony <sam@samanthony.xyz>2024-12-01 20:50:33 -0500
committerSam Anthony <sam@samanthony.xyz>2024-12-01 20:50:33 -0500
commit4382f9dcbe097b86c957ba028e2bcab6ca384f58 (patch)
tree618a7ec568bf406bc117a964f45f8e55cfb4795d /src/main/java/derms/net/tomulticast/TotalOrderMulticastReceiver.java
parent90529cfd7ef1f38ddb25449ea85cceba036ecd57 (diff)
downloadsoen423-4382f9dcbe097b86c957ba028e2bcab6ca384f58.zip
pass NetworkInterface to TotalOrderMulticastReceiver
Diffstat (limited to 'src/main/java/derms/net/tomulticast/TotalOrderMulticastReceiver.java')
-rw-r--r--src/main/java/derms/net/tomulticast/TotalOrderMulticastReceiver.java18
1 files changed, 18 insertions, 0 deletions
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<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 TotalOrderMulticastReceiver(InetSocketAddress group, InetAddress laddr, NetworkInterface ifs) throws IOException {
+ this.deliver = new LinkedBlockingQueue<Message<T>>();
+ this.log = Logger.getLogger(getClass().getName());
+
+ this.pool = Executors.newSingleThreadExecutor();
+ this.receiver = new Receive<T>(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<Message<T>>();