`
Donald_Draper
  • 浏览: 950847 次
社区版块
存档分类
最新评论

MulticastChanne接口定义

    博客分类:
  • NIO
nio 
阅读更多
NetworkChannel接口定义:http://donald-draper.iteye.com/blog/2369773
MembershipKey定义:http://donald-draper.iteye.com/blog/2372947
package java.nio.channels;
import java.net.InetAddress;
import java.net.NetworkInterface;
import java.io.IOException;
import java.net.ProtocolFamily;             // javadoc
import java.net.StandardProtocolFamily;     // javadoc
import java.net.StandardSocketOptions;      // javadoc

/**
 * A network channel that supports Internet Protocol (IP) multicasting.
 *MulticastChannel是一个支持多播网络IP协议的网络通道
 *  IP multicasting is the transmission of IP datagrams to members of
 * a [i]group[/i] that is zero or more hosts identified by a single destination
 * address.
 *IP多播是传输IP报文到多播组目的地址的一个或多个主机。
 * <p> In the case of a channel to an {@link StandardProtocolFamily#INET IPv4} socket,
 * the underlying operating system supports <a href="http://www.ietf.org/rfc/rfc2236.txt">
 * <i>RFC 2236: Internet Group Management Protocol, Version 2 (IGMPv2)</i></a>.
 * It may optionally support source filtering as specified by <a
 * href="http://www.ietf.org/rfc/rfc3376.txt"> <i>RFC 3376: Internet Group
 * Management Protocol, Version 3 (IGMPv3)</i></a>.
 * For channels to an {@link StandardProtocolFamily#INET6 IPv6} socket, the equivalent
 * standards are <a href="http://www.ietf.org/rfc/rfc2710.txt"> <i>RFC 2710:
 * Multicast Listener Discovery (MLD) for IPv6</i></a> and <a
 * href="http://www.ietf.org/rfc/rfc3810.txt"> <i>RFC 3810: Multicast Listener
 * Discovery Version 2 (MLDv2) for IPv6</i></a>.
 *
 一个ip4的socket网络通道底层支持IGMPv2,可以源地址过滤的IGMPv3。一个IPv6的socket网络通道
 ,对应的为MLD,MLDv2。

 * <p> The {@link #join(InetAddress,NetworkInterface)} method is used to
 * join a group and receive all multicast datagrams sent to the group. A channel
 * may join several multicast groups and may join the same group on several
 * {@link NetworkInterface interfaces}. Membership is dropped by invoking the {@link
 * MembershipKey#drop drop} method on the returned {@link MembershipKey}. If the
 * underlying platform supports source filtering then the {@link MembershipKey#block
 * block} and {@link MembershipKey#unblock unblock} methods can be used to block or
 * unblock multicast datagrams from particular source addresses.
 *join(InetAddress,NetworkInterface)方法加入一个多播组,接受发送到多播组的报文。
一个多播通道可以加入多个多播分组,或加入多个网卡接口的相同多播分组。调用MembershipKey的
drop方法,将会丢弃Membership,即MembershipKey无效。如果底层操作系统支持源地址过滤,则
可以调用MembershipKey#block和#unblock方法,用于阻塞从特殊源地址的报文或解除从特殊源地址的报文阻塞。
 * <p> The {@link #join(InetAddress,NetworkInterface,InetAddress)} method
 * is used to begin receiving datagrams sent to a group whose source address matches
 * a given source address. This method throws {@link UnsupportedOperationException}
 * if the underlying platform does not support source filtering.  Membership is
 * [i]cumulative[/i] and this method may be invoked again with the same group
 * and interface to allow receiving datagrams from other source addresses. The
 * method returns a {@link MembershipKey} that represents membership to receive
 * datagrams from the given source address. Invoking the key's {@link
 * MembershipKey#drop drop} method drops membership so that datagrams from the
 * source address can no longer be received.
 *#join(InetAddress,NetworkInterface,InetAddress)方法为,加入一个多播组,
 开始接受发送到多播组的源地址报文。如果底层平台不支持源地址过滤,则抛出UnsupportedOperationException。
多播组成员关系是可以累加的,,此方法以相同的多播地址和网络接口参数可以多次调用,
即允许接受多个源地址发送到多播组的报文。此方法返回一个表示接受指定源地址报文的多播关系key。
调用MembershipKey#drop方法,将解除多播成员关系,即不在接受源地址发送的多播报文。
 * <h4>Platform dependencies</h4>
 *平台依赖性
 * The multicast implementation is intended to map directly to the native
 * multicasting facility. Consequently, the following items should be considered
 * when developing an application that receives IP multicast datagrams:
 *多播的实现是需要直接映射到本地的多播硬件设备。因此在开发一个接受多播ip的报文时,
 需要考虑一下几条:
 * [list=1]
 *
 * <li><p> The creation of the channel should specify the {@link ProtocolFamily}
 * that corresponds to the address type of the multicast groups that the channel
 * will join. There is no guarantee that a channel to a socket in one protocol
 * family can join and receive multicast datagrams when the address of the
 * multicast group corresponds to another protocol family. For example, it is
 * implementation specific if a channel to an {@link StandardProtocolFamily#INET6 IPv6}
 * socket can join an {@link StandardProtocolFamily#INET IPv4} multicast group and receive
 * multicast datagrams sent to the group. 
</li>
 *通道创建时应该确定通道加入的多播组地址类型的ProtocolFamily。多播通道不能保证,
 一个ProtocolFamily类型的socket可以接受另外一个ProtocolFamily类型的多播组报文,或者说
 不能保证能加入另外一个ProtocolFamily类型多播组。比如通道的socket的协议组为StandardProtocolFamily#INET6 IPv6
 ,而加入的多播组为StandardProtocolFamily#INET IPv4。这段话的含义为,通道在创建关联一个
 协议ProtocolFamily,具体的协议通道,只能加入相应的多播协议组。及INET6通道只能加入ip6地址多播组,
INET通道只能加入ip4地址多播组。

//DatagramChannel,打开一个指定协议的报文通道
public static DatagramChannel open(ProtocolFamily family) throws IOException {
        return SelectorProvider.provider().openDatagramChannel(family);
    }
 * <li> The channel's socket should be bound to the {@link
 * InetAddress#isAnyLocalAddress wildcard} address. If the socket is bound to
 * a specific address, rather than the wildcard address then it is implementation
 * specific if multicast datagrams are received by the socket. 
</li>
 *通道应该绑定一个本地地址。如果绑定为一个特定的地址,而不是本地地址,具体的通道实现
 需要确定是否多播报文可以通过socket接受。
 * <li> The {@link StandardSocketOptions#SO_REUSEADDR SO_REUSEADDR} option should be
 * enabled prior to {@link NetworkChannel#bind binding} the socket. This is
 * required to allow multiple members of the group to bind to the same
 * address. 
</li>
 *StandardSocketOptions#SO_REUSEADDR应该在地址绑定前,配置地址重用选项。
 以便多个成员能够绑定同样的地址,加入多播组。
 * [/list]
 *
 * <p> <b>Usage Example:</b>
 * <pre>使用实例
 *     // join multicast group on this interface, and also use this
 *     // interface for outgoing multicast datagrams
       加入一个指定网卡的多播组,同时用这个网卡发送多播报文
 *     NetworkInterface ni = NetworkInterface.getByName("hme0");
 *
 *     DatagramChannel dc = DatagramChannel.open(StandardProtocolFamily.INET)
 *         .setOption(StandardSocketOptions.SO_REUSEADDR, true)
 *         .bind(new InetSocketAddress(5000))
 *         .setOption(StandardSocketOptions.IP_MULTICAST_IF, ni);
 *
 *     InetAddress group = InetAddress.getByName("225.4.5.6");
 *
 *     MembershipKey key = dc.join(group, ni);
 * </pre>
 *
 * @since 1.7
 */
//多播通道
public interface MulticastChannel
    extends NetworkChannel
{
    /**
     * Closes this channel.
     *关闭通道
     * <p> If the channel is a member of a multicast group then the membership
     * is {@link MembershipKey#drop dropped}. Upon return, the {@link
     * MembershipKey membership-key} will be {@link MembershipKey#isValid
     * invalid}.
     *如果通道是一个多播组的成员,在通道关闭时,将会drop相应的MembershipKey。
     在方法执行后,MembershipKey将会无效
     * <p> This method otherwise behaves exactly as specified by the {@link
     * Channel} interface.
     *此方法在其他方面与通道接口相似。
     * @throws  IOException
     *          If an I/O error occurs
     */
    @Override void close() throws IOException;

    /**
     * Joins a multicast group to begin receiving all datagrams sent to the group,
     * returning a membership key.
     *加入一个多播组,开始接受发送到多播组的报文,返回MembershipKey。
     * <p> If this channel is currently a member of the group on the given
     * interface to receive all datagrams then the membership key, representing
     * that membership, is returned. Otherwise this channel joins the group and
     * the resulting new membership key is returned. The resulting membership key
     * is not {@link MembershipKey#sourceAddress source-specific}.
     *如果为指定网络接口地址的组成员,正在接受所有报文,将返回表示成员关系的MembershipKey。
     否则通道加入分组,创建一个新的MembershipKey返回。MembershipKey的源地址是不确定的。
     * <p> A multicast channel may join several multicast groups, including
     * the same group on more than one interface. An implementation may impose a
     * limit on the number of groups that may be joined at the same time.
     *一个多播通道可以加入多个多播分组,包括在一个或多个网络接口上的相同分组。一个具体
     的实现也许会限制同一时间加入多播组的数量。
     * @param   group
     *          The multicast address to join
     * @param   interf
     *          The network interface on which to join the group
     *
     * @return  The membership key
     *
     * @throws  IllegalArgumentException,多播组地址为非多播地址,或通道不支持多播组地址参数
     *          If the group parameter is not a {@link InetAddress#isMulticastAddress
     *          multicast} address, or the group parameter is an address type
     *          that is not supported by this channel
     * @throws  IllegalStateException,如果通道已经加入源地址确定的对应的网络接口上的多播组
     *          If the channel already has source-specific membership of the
     *          group on the interface
     * @throws  UnsupportedOperationException 如果通道不是一个网络写socket
     *          If the channel's socket is not an Internet Protocol socket
     * @throws  ClosedChannelException
     *          If this channel is closed
     * @throws  IOException
     *          If an I/O error occurs
     * @throws  SecurityException
     *          If a security manager is set, and its
     *          {@link SecurityManager#checkMulticast(InetAddress) checkMulticast}
     *          method denies access to the multiast group
     */
    MembershipKey join(InetAddress group, NetworkInterface interf)
        throws IOException;

    /**
     * Joins a multicast group to begin receiving datagrams sent to the group
     * from a given source address.
     *加入一个多播组,开始接受发送到多播组的源地址报文,返回MembershipKey。
     * <p> If this channel is currently a member of the group on the given
     * interface to receive datagrams from the given source address then the
     * membership key, representing that membership, is returned. Otherwise this
     * channel joins the group and the resulting new membership key is returned.
     * The resulting membership key is {@link MembershipKey#sourceAddress
     * source-specific}.
     *如果为指定网络接口地址的组成员,正在接受所有源地址的报文,将返回表示成员关系的MembershipKey。
     否则通道加入分组,创建一个新的MembershipKey返回。MembershipKey的源地址是确定的。
     * <p> Membership is [i]cumulative[/i] and this method may be invoked
     * again with the same group and interface to allow receiving datagrams sent
     * by other source addresses to the group.
     *多播组成员关系是可以累加的,此方法以相同的多播地址和网络接口参数可以多次调用,
     即允许从多个源地址发送报文到多播组。
     * @param   group
     *          The multicast address to join
     * @param   interf
     *          The network interface on which to join the group
     * @param   source
     *          The source address
     *
     * @return  The membership key
     *
     * @throws  IllegalArgumentException
     *          If the group parameter is not a {@link
     *          InetAddress#isMulticastAddress multicast} address, the
     *          source parameter is not a unicast address, the group
     *          parameter is an address type that is not supported by this channel,
     *          or the source parameter is not the same address type as the group
     * @throws  IllegalStateException
     *          If the channel is currently a member of the group on the given
     *          interface to receive all datagrams
     * @throws  UnsupportedOperationException
     *          If the channel's socket is not an Internet Protocol socket or
     *          source filtering is not supported
     * @throws  ClosedChannelException
     *          If this channel is closed
     * @throws  IOException
     *          If an I/O error occurs
     * @throws  SecurityException
     *          If a security manager is set, and its
     *          {@link SecurityManager#checkMulticast(InetAddress) checkMulticast}
     *          method denies access to the multiast group
     */
    MembershipKey join(InetAddress group, NetworkInterface interf, InetAddress source)
        throws IOException;
}
0
1
分享到:
评论

相关推荐

    电信塔施工方案.doc

    5G通信行业、网络优化、通信工程建设资料。

    29-【智慧城市与政府治理分会场】10亿大数据助推都市治理-30页.pdf

    29-【智慧城市与政府治理分会场】10亿大数据助推都市治理-30页.pdf

    ABB IRC5 Compact 机器人产品手册

    ABB IRC5 Compact 机器人产品手册

    LTE容量优化高负荷小区优化指导书.docx

    5G通信行业、网络优化、通信工程建设资料

    施工工艺及质量检查记录表.docx

    5G通信行业、网络优化、通信工程建设资料。

    25G无源波分安装规范指导.docx

    5G通信、网络优化与通信建设

    基于Springboot+Vue在线宠物用品交易网站毕业源码案例设计.zip

    网络技术和计算机技术发展至今,已经拥有了深厚的理论基础,并在现实中进行了充分运用,尤其是基于计算机运行的软件更是受到各界的关注。加上现在人们已经步入信息时代,所以对于信息的宣传和管理就很关键。系统化是必要的,设计网上系统不仅会节约人力和管理成本,还会安全保存庞大的数据量,对于信息的维护和检索也不需要花费很多时间,非常的便利。 网上系统是在MySQL中建立数据表保存信息,运用SpringBoot框架和Java语言编写。并按照软件设计开发流程进行设计实现。系统具备友好性且功能完善。 网上系统在让售信息规范化的同时,也能及时通过数据输入的有效性规则检测出错误数据,让数据的录入达到准确性的目的,进而提升数据的可靠性,让系统数据的错误率降至最低。 关键词:vue;MySQL;SpringBoot框架 【引流】 Java、Python、Node.js、Spring Boot、Django、Express、MySQL、PostgreSQL、MongoDB、React、Angular、Vue、Bootstrap、Material-UI、Redis、Docker、Kubernetes

    通信各专业(管道、线路、设备)安全操作规程.docx

    5G通信行业、网络优化、通信工程建设资料

    node-v12.13.1-x86.msi

    Node.js,简称Node,是一个开源且跨平台的JavaScript运行时环境,它允许在浏览器外运行JavaScript代码。Node.js于2009年由Ryan Dahl创立,旨在创建高性能的Web服务器和网络应用程序。它基于Google Chrome的V8 JavaScript引擎,可以在Windows、Linux、Unix、Mac OS X等操作系统上运行。 Node.js的特点之一是事件驱动和非阻塞I/O模型,这使得它非常适合处理大量并发连接,从而在构建实时应用程序如在线游戏、聊天应用以及实时通讯服务时表现卓越。此外,Node.js使用了模块化的架构,通过npm(Node package manager,Node包管理器),社区成员可以共享和复用代码,极大地促进了Node.js生态系统的发展和扩张。 Node.js不仅用于服务器端开发。随着技术的发展,它也被用于构建工具链、开发桌面应用程序、物联网设备等。Node.js能够处理文件系统、操作数据库、处理网络请求等,因此,开发者可以用JavaScript编写全栈应用程序,这一点大大提高了开发效率和便捷性。 在实践中,许多大型企业和组织已经采用Node.js作为其Web应用程序的开发平台,如Netflix、PayPal和Walmart等。它们利用Node.js提高了应用性能,简化了开发流程,并且能更快地响应市场需求。

    C#Gif动画录制软件是一款方便好用的小软件源码.zip

    Gif动画录制软件是一款方便好用的小软件,使用此工具,您可以记录屏幕的选定区域,网络摄像头的实时提要或草图板上的实时图形。之后,您可以编辑动画并将其另存为gif,apng,视频,psd或png图像。

    协同供应链集成详细功能介绍V70.rar

    协同供应链集成(Collaborative Supply Chain Integration,CSCD是数字化转型解决方案中的重要一环,旨在通过技术手段实现供应链各环节的无缝对接与高效协作。V70版本作为该解决方案的一个升级版,可能包含了更加先进的功能和工具,以支持企业在复杂的商业环境中保持竞争力。这个资料包“协同供应链集成详细功能介绍V70.rar”很可能提供了对V70版本功能的深入剖析,包括了如何利用最新的数字化工具和技术来优化库存管理、订单处理、物流跟踪、供应商管理以及客户关系管理等关键供应链过程。它可能详细介绍了实时数据共享、自动化流程、预测分析、风险管理和智能决策支持系统等创新功能,这些功能有助于减少供应链中断,提高透明度,降低运营成本,并增强整个供应链网络的响应能力。通过这个资料,企业可以获得实施协同供应链集成的全面指导,了解如何通过集成的信息系统和平台,实现数据的一致性和准确性,以及如何通过合作伙伴之间的紧密协作,提升整个供应链的效率和灵活性。这对于追求数字化转型的企业来说,是一个宝贵的资源,因为它不仅提供了理论框架,还可能包含了实际案例研究、最佳实践和实施策略,帮助企业

    英飞凌官方ADS库1.9.20版

    英飞凌官方ADS库1.9.20版

    node-v7.7.3.tar.xz

    Node.js,简称Node,是一个开源且跨平台的JavaScript运行时环境,它允许在浏览器外运行JavaScript代码。Node.js于2009年由Ryan Dahl创立,旨在创建高性能的Web服务器和网络应用程序。它基于Google Chrome的V8 JavaScript引擎,可以在Windows、Linux、Unix、Mac OS X等操作系统上运行。 Node.js的特点之一是事件驱动和非阻塞I/O模型,这使得它非常适合处理大量并发连接,从而在构建实时应用程序如在线游戏、聊天应用以及实时通讯服务时表现卓越。此外,Node.js使用了模块化的架构,通过npm(Node package manager,Node包管理器),社区成员可以共享和复用代码,极大地促进了Node.js生态系统的发展和扩张。 Node.js不仅用于服务器端开发。随着技术的发展,它也被用于构建工具链、开发桌面应用程序、物联网设备等。Node.js能够处理文件系统、操作数据库、处理网络请求等,因此,开发者可以用JavaScript编写全栈应用程序,这一点大大提高了开发效率和便捷性。 在实践中,许多大型企业和组织已经采用Node.js作为其Web应用程序的开发平台,如Netflix、PayPal和Walmart等。它们利用Node.js提高了应用性能,简化了开发流程,并且能更快地响应市场需求。

    node-v11.1.0-linux-armv7l.tar.gz

    Node.js,简称Node,是一个开源且跨平台的JavaScript运行时环境,它允许在浏览器外运行JavaScript代码。Node.js于2009年由Ryan Dahl创立,旨在创建高性能的Web服务器和网络应用程序。它基于Google Chrome的V8 JavaScript引擎,可以在Windows、Linux、Unix、Mac OS X等操作系统上运行。 Node.js的特点之一是事件驱动和非阻塞I/O模型,这使得它非常适合处理大量并发连接,从而在构建实时应用程序如在线游戏、聊天应用以及实时通讯服务时表现卓越。此外,Node.js使用了模块化的架构,通过npm(Node package manager,Node包管理器),社区成员可以共享和复用代码,极大地促进了Node.js生态系统的发展和扩张。 Node.js不仅用于服务器端开发。随着技术的发展,它也被用于构建工具链、开发桌面应用程序、物联网设备等。Node.js能够处理文件系统、操作数据库、处理网络请求等,因此,开发者可以用JavaScript编写全栈应用程序,这一点大大提高了开发效率和便捷性。 在实践中,许多大型企业和组织已经采用Node.js作为其Web应用程序的开发平台,如Netflix、PayPal和Walmart等。它们利用Node.js提高了应用性能,简化了开发流程,并且能更快地响应市场需求。

    通信工程质量控制方案.docx

    5G通信行业、网络优化、通信工程建设资料。

    5GC参数设置问题导致UE无法接入.docx

    5G通信行业、网络优化、通信工程建设资料

    动力机房--低压市电、基础勘察设计知识.pptx

    5G通信行业、网络优化、通信工程建设资料

    jump(1).mobileprovision

    jump(1).mobileprovision

    node-v6.14.3-aix-ppc64.tar.gz

    Node.js,简称Node,是一个开源且跨平台的JavaScript运行时环境,它允许在浏览器外运行JavaScript代码。Node.js于2009年由Ryan Dahl创立,旨在创建高性能的Web服务器和网络应用程序。它基于Google Chrome的V8 JavaScript引擎,可以在Windows、Linux、Unix、Mac OS X等操作系统上运行。 Node.js的特点之一是事件驱动和非阻塞I/O模型,这使得它非常适合处理大量并发连接,从而在构建实时应用程序如在线游戏、聊天应用以及实时通讯服务时表现卓越。此外,Node.js使用了模块化的架构,通过npm(Node package manager,Node包管理器),社区成员可以共享和复用代码,极大地促进了Node.js生态系统的发展和扩张。 Node.js不仅用于服务器端开发。随着技术的发展,它也被用于构建工具链、开发桌面应用程序、物联网设备等。Node.js能够处理文件系统、操作数据库、处理网络请求等,因此,开发者可以用JavaScript编写全栈应用程序,这一点大大提高了开发效率和便捷性。 在实践中,许多大型企业和组织已经采用Node.js作为其Web应用程序的开发平台,如Netflix、PayPal和Walmart等。它们利用Node.js提高了应用性能,简化了开发流程,并且能更快地响应市场需求。

    Exam2024SpringA.ipynb

    Exam2024SpringA.ipynb

Global site tag (gtag.js) - Google Analytics