package java.nio.channels;
import java.net.InetAddress;
import java.net.NetworkInterface;
import java.io.IOException;
/**
* A token representing the membership of an Internet Protocol (IP) multicast
* group.
*MembershipKey表示一个网络IP协议的多播分组成员信息token
* <p> A membership key may represent a membership to receive all datagrams sent
* to the group, or it may be [i]source-specific[/i], meaning that it
* represents a membership that receives only datagrams from a specific source
* address. Whether or not a membership key is source-specific may be determined
* by invoking its {@link #sourceAddress() sourceAddress} method.
*一个MembershipKey表示一个多播组成员接受发送到多播组的报文的关系,如果源地址确定,
表示直接接受来至源地址的报文。我们可以通过#sourceAddress来判断源地址是否确定。
* <p> A membership key is valid upon creation and remains valid until the
* membership is dropped by invoking the {@link #drop() drop} method, or
* the channel is closed. The validity of the membership key may be tested
* by invoking its {@link #isValid() isValid} method.
*一个多播组成员关系在创建时,是有效的,直到MembershipKey调用#drop方法,之前他都是有效。
我们可以调用#isValid()来判断其是否有效。
* <p> Where a membership key is not source-specific and the underlying operation
* system supports source filtering, then the {@link #block block} and {@link
* #unblock unblock} methods can be used to block or unblock multicast datagrams
* from particular source addresses.
*如果MembershipKey的源地址是不确定的,底层操作系统支持源地址过滤,调用#block和#unblock将会
阻塞和解除阻塞从源地址发送过来的报文
* @see MulticastChannel
*
* @since 1.7
*/
public abstract class MembershipKey {
/**
* Initializes a new instance of this class.
*/
protected MembershipKey() {
}
/**
* Tells whether or not this membership is valid.
*判断一个MembershipKey是否有效
* <p> A multicast group membership is valid upon creation and remains
* valid until the membership is dropped by invoking the {@link #drop() drop}
* method, or the channel is closed.
*一个多播组成员关系在创建时,是有效的,直到MembershipKey调用#drop方法,之前他都是有效。
* @return {@code true} if this membership key is valid, {@code false}
* otherwise
*/
public abstract boolean isValid();
/**
* Drop membership.
*丢弃组成员关系membership
* <p> If the membership key represents a membership to receive all datagrams
* then the membership is dropped and the channel will no longer receive any
* datagrams sent to the group. If the membership key is source-specific
* then the channel will no longer receive datagrams sent to the group from
* that source address.
*如果MembershipKey表示,MembershipKey接受所有报文,当drop方法调用时,通道不在接受
任何报文发送给多播组。如果MembershipKey的源地址是确定的,那么通道不在接受
任何报文发送给源地址的多播组。
* <p> After membership is dropped it may still be possible to receive
* datagrams sent to the group. This can arise when datagrams are waiting to
* be received in the socket's receive buffer. After membership is dropped
* then the channel may {@link MulticastChannel#join join} the group again
* in which case a new membership key is returned.
*在多播成员关系drop之后,仍有可能接受发送到多播组的报文。则个可能引起socket的接收
缓冲区的报文等待被接收。在多播成员关系drop之后,通道有可能调用MulticastChannel#join
方法加入分组,这样一个新的MembershipKey将会被创建返回。
* <p> Upon return, this membership object will be {@link #isValid() invalid}.
* If the multicast group membership is already invalid then invoking this
* method has no effect. Once a multicast group membership is invalid,
* it remains invalid forever.
drop多播成员关系drop之后,#isValid()方法将会返回fasle,即无效。如果MembershipKey已经无效,
则调用此方将没有任何影响。一旦多播关系为无效的,则永久无效。
*/
public abstract void drop();
/**
* Block multicast datagrams from the given source address.
*阻塞从源地址发送过来的多播报文
* <p> If this membership key is not source-specific, and the underlying
* operating system supports source filtering, then this method blocks
* multicast datagrams from the given source address. If the given source
* address is already blocked then this method has no effect.
* After a source address is blocked it may still be possible to receive
* datagams from that source. This can arise when datagrams are waiting to
* be received in the socket's receive buffer.
*如果MembershipKey的源地址是不确定的,底层操作系统支持源地址过滤,此方法将会
阻塞从源地址发送过来的多播报文。如果源地址已经被阻塞,再次调用任何影响。
在源地址阻塞后,仍有可能接受源地址的报文。则个可能引起socket的接收
缓冲区中的报文等待被接收。
* @param source
* The source address to block
*
* @return This membership key
*
* @throws IllegalArgumentException
* If the {@code source} parameter is not a unicast address or
* is not the same address type as the multicast group
* @throws IllegalStateException
* If this membership key is source-specific or is no longer valid
* @throws UnsupportedOperationException
* If the underlying operating system does not support source
* filtering
* @throws IOException
* If an I/O error occurs
*/
public abstract MembershipKey block(InetAddress source) throws IOException;
/**
* Unblock multicast datagrams from the given source address that was
* previously blocked using the {@link #block(InetAddress) block} method.
*解除从源地址发送过来多播报文的阻塞
* @param source
* The source address to unblock
*
* @return This membership key
*
* @throws IllegalStateException
* If the given source address is not currently blocked or the
* membership key is no longer valid
*/
public abstract MembershipKey unblock(InetAddress source);
/**
* Returns the channel for which this membership key was created. This
* method will continue to return the channel even after the membership
* becomes {@link #isValid invalid}.
*返回创建多播成员关系key的通道,在多播成员关系key无效时,仍返回通道
* @return the channel
*/
public abstract MulticastChannel channel();
/**
* Returns the multicast group for which this membership key was created.
* This method will continue to return the group even after the membership
* becomes {@link #isValid invalid}.
*返回创建多播关系key的多播分组。在多播成员关系key无效时,仍返回分组地址信息
* @return the multicast group
*/
public abstract InetAddress group();
/**
* Returns the network interface for which this membership key was created.
* This method will continue to return the network interface even after the
* membership becomes {@link #isValid invalid}.
*返回创建多播成员关系key的网络接口信息。在多播成员关系key无效时,仍返回网络接口信息
* @return the network interface
*/
public abstract NetworkInterface networkInterface();
/**
* Returns the source address if this membership key is source-specific,
* or {@code null} if this membership is not source-specific.
*如果多播成员关系key的源地址是确定的则返回相应的源地址,否则返回null
* @return The source address if this membership key is source-specific,
* otherwise {@code null}
*/
public abstract InetAddress sourceAddress();
}
//NetworkInterface
package java.net;
import java.util.Enumeration;
import java.util.NoSuchElementException;
import sun.security.action.*;
import java.security.AccessController;
/**
* This class represents a Network Interface made up of a name,
* and a list of IP addresses assigned to this interface.
* It is used to identify the local interface on which a multicast group
* is joined.
*
* Interfaces are normally known by names such as "le0".
*
* @since 1.4
*/
public final class NetworkInterface {
private String name;
private String displayName;
private int index;
private InetAddress addrs[];
private InterfaceAddress bindings[];
private NetworkInterface childs[];
private NetworkInterface parent = null;
private boolean virtual = false;
private static final NetworkInterface defaultInterface;
private static final int defaultIndex; /* index of defaultInterface */
}
分享到:
相关推荐
一款基于机器学习的Web日志统计分析与异常检测命令行工具_hy4
基于RBAC权限控制的资产管理系统_hy5
318 Series Hardened Access Points 370 Series Outdoor Access Points 310 Series Campus Access Points IAP-315 IAP-314
最强PMP备考计划、知识整理、试题,并以本系统来展示_hy5
【官方】计算机职业英语一级考试样卷.pdf 【官方】全国机等级考试二级笔试样卷:存取(Access)数据库程序设计.pdf 【官方】全国计算机等级考试二级笔试样卷:C++语言程序设计.pdf 【官方】全国计算机等级考试二级笔试样卷:C语言程序设计.pdf 【官方】全国机等级考试二级笔试样卷:德尔菲(Delphi)语言程序设计.pdf 【官方】全国机等级考试二级笔试样卷:Java语言程序设计.pdf 【官方】全国机等级考试二级笔试样卷:视觉基础语言程序设计.pdf 【官方】全国机等级考试二级笔试样卷:视讯FoxPro数据库程序设计.pdf 【官方】全国计算机等级考试三级笔试样卷:PC技术,pdf 【官方】全国计算机等级考试三级笔试样卷:网络技术.pdf 【官方】全国计算机等级考试三级笔试样卷:信息管理技术,pdf 【官方】全国计算机等级考试四级笔试样卷:软件测试工程师.pdf 【官方】全国计算机等级考试四级笔试样卷:数据库工程师,pdf 【官方】全国计算机等级考试四级笔试样卷:数据库技术,pdf 【官方】全国计算机等级考试四级笔试样卷:网络工程师.pdf
SpringBoot网上商城#java#毕业设计#网上商城#springboot#课程设计#编程#thymeleaf_hy4
1.版本:matlab2014/2019a/2024a 2.附赠案例数据可直接运行matlab程序。 3.代码特点:参数化编程、参数可方便更改、代码编程思路清晰、注释明细。 4.适用对象:计算机,电子信息工程、数学等专业的大学生课程设计、期末大作业和毕业设计。
1.版本:matlab2014/2019a/2024a 2.附赠案例数据可直接运行matlab程序。 3.代码特点:参数化编程、参数可方便更改、代码编程思路清晰、注释明细。 4.适用对象:计算机,电子信息工程、数学等专业的大学生课程设计、期末大作业和毕业设计。
360 Series Outdoor Access Points 303 Series Campus Access Points 303H Series Hospitality Access Points 300 Series Campus Access Points
肽质量指纹图谱提取区域检测系统源码分享[一条龙教学YOLOV8标注好的数据集一键训练_70+全套改进创新点发刊_Web前端展示]
分布式事务实战_hy4
python网络爬虫按月爬cctv新闻30分的视频_hy4
【golang】企业微信群机器人接口Golang封装
1.版本:matlab2014/2019a/2024a 2.附赠案例数据可直接运行matlab程序。 3.代码特点:参数化编程、参数可方便更改、代码编程思路清晰、注释明细。
mumu-activemq是一个对老牌mq消息中间件的学习和测试项目,本人通过这个项目来熟悉activemq的消息发送流_hy4
【Python+HTML】基于flask的rbac学生权限管理系统,redis存储session_pgj
一步一步学springboot2:微服务项目实战(第二版)_hy5
1.版本:matlab2014/2019a/2024a 2.附赠案例数据可直接运行matlab程序。 3.代码特点:参数化编程、参数可方便更改、代码编程思路清晰、注释明细。
新建 DOC 文档.doc
1.版本:matlab2014/2019a/2024a 2.附赠案例数据可直接运行matlab程序。 3.代码特点:参数化编程、参数可方便更改、代码编程思路清晰、注释明细。