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 */
}
分享到:
相关推荐
少儿编程scratch项目源代码文件案例素材-直升机飞行.zip
wanjunshe_Python-Tensorflow_12888_1745868924470
健康监测_Android开发_BLE蓝牙通信_心率数据采集与存储_基于小米手环2的实时心率监测应用_支持后台长时间运行的心率记录工具_可导出SQLite数据库的心率数据分析系统_适
少儿编程scratch项目源代码文件案例素材-种花模拟器.zip
嵌入式系统开发_FreeRTOS实时操作系统_STM32F103C8T6微控制器_OLED显示屏_DHT11温湿度传感器_多任务调度_多级菜单设计_万年历算法_电子闹钟功能_参数配
基于python实现的粒子群的VRP(车辆配送路径规划)问题建模求解+源码+项目文档+算法解析,适合毕业设计、课程设计、项目开发。项目源码已经过严格测试,可以放心参考并在此基础上延申使用,详情见md文档 算法设计的关键在于如何向表现较好的个体学习,标准粒子群算法引入惯性因子w、自我认知因子c1、社会认知因子c2分别作为自身、当代最优解和历史最优解的权重,指导粒子速度和位置的更新,这在求解函数极值问题时比较容易实现,而在VRP问题上,速度位置的更新则难以直接采用加权的方式进行,一个常见的方法是采用基于遗传算法交叉算子的混合型粒子群算法进行求解,这里采用顺序交叉算子,对惯性因子w、自我认知因子c1、社会认知因子c2则以w/(w+c1+c2),c1/(w+c1+c2),c2/(w+c1+c2)的概率接受粒子本身、当前最优解、全局最优解交叉的父代之一(即按概率选择其中一个作为父代,不加权)。 算法设计的关键在于如何向表现较好的个体学习,标准粒子群算法引入惯性因子w、自我认知因子c1、社会认知因子c2分别作为自身、当代最优解和历史最优解的权重,指导粒子速度和位置的更新,这在求解函数极值问题时比较容易实现,而在VRP问题上,速度位置的更新则难以直接采用加权的方式进行,一个常见的方法是采用基于遗传算法交叉算子的混合型粒子群算法进行求解,这里采用顺序交叉算子,对惯性因子w、自我认知因子c1、社会认知因子c2则以w/(w+c1+c2),c1/(w+c1+c2),c2/(w+c1+c2)的概率接受粒子本身、当前最优解、全局最优解交叉的父代之一(即按概率选择其中一个作为父代,不加权)。
scratch少儿编程逻辑思维游戏源码-猫猫粉碎.zip
scratch少儿编程逻辑思维游戏源码-蓝胡子.zip
scratch少儿编程逻辑思维游戏源码-美食大亨.zip
scratch少儿编程逻辑思维游戏源码-洛克人.zip
scratch少儿编程逻辑思维游戏源码-龙冲刺.zip
思幻个人引导页V2.2版本11月29日更新.zip
scratch少儿编程逻辑思维游戏源码-骑士风斩法.zip
移动应用开发_H5CSS3ionicng-cordovaMVVM模式_基于HTML5和CSS3技术实现多页面布局ionic指令数据绑定ui-route单页跳转调用手机
少儿编程scratch项目源代码文件案例素材-植物大战僵尸创造版 Ver. 1.0.3.zip
scratch少儿编程逻辑思维游戏源码-日落(2).zip
动态星空背景个人主页(带后台).zip
scratch少儿编程逻辑思维游戏源码-迷雾森林:诞生 3.2 起源觉醒.zip
lib文件
影剧院音乐厅微信小程序源码,包括资讯动态,演出信息,艺术教育,经典 剧目,商务合作,关于我们,公益演出预约,商业演出预约,演出日历,我的今日预约,我的预约码,后台预约管理,后台预约核销,后台CMS内容管理等功能模块。是一个数字化的艺术殿堂公共平台,无需下载安装,让您能够随时随地便捷地走近乐团、走近交响乐 演出预约管理:开始/截止时间/人数均可灵活设置,可以自定义客户预约 填写的数据项 演出预约凭证:支持线下到场后校验签到/核销/二维码自助签到等多种方式 详尽的演出预约数据:支持预约名单数据导出Excel,打印