The JxtaMulticastSocket class is useful for sending and receiving JXTA multicast packets. A JxtaMulticastSocket is a (UDP) DatagramSocket, with additional capabilities for joining "groups" of other multicast hosts on the internet. A multicast group is specified within the context of PeerGroup and a propagate pipe advertisement. One would join a multicast group by first creating a MulticastSocket with the desired peer group and pipe advertisement :
// join a Multicast group and send the group salutations
...
String msg = "Hello";
MulticastSocket s = new JxtaMulticastSocket(peergroup, propPipeAdv);
//We are joined at this point
DatagramPacket hi = new DatagramPacket(msg.getBytes(), msg.length());
s.send(hi);
// get their responses!
byte[] buf = new byte[1000];
DatagramPacket recv = new DatagramPacket(buf, buf.length);
s.receive(recv);
...
// OK, I'm done talking - leave the group...
s.close();
One can also respond only to the sender of the datagram as follows :
DatagramPacket res = new DatagramPacket(response.getBytes(), response.length());
res.setAddress(recv.getAddress());
s.send(res);
When one sends a message to a multicast group, all subscribing recipients to that peergroup and pipe receive the message (including themselves) When a socket subscribes to a multicast group/port, it receives datagrams sent by other hosts to the group/pipe, as do all other members of the group and pipe. A socket relinquishes membership in a group by the close() method. Multiple MulticastSocket's may subscribe to a multicast group and pipe concurrently, and they will all receive group datagrams. When a datagram is sent it carries along with the peerid of the sender. The PeerID is represented as a InetAddress in the form of host/ipadress where host name is the peerid, and ip address is always represented as 0.0.0.0 since it is meaningless in the context of JXTA. e.g of InetAddress resembles the following:
uuid-59616261646162614A787461503250339C6014B0F21A49DBBDF2ADBDDBCB314703/0.0.0.0
分享到:
相关推荐
解决 Can not find the main class. Program will exit. 难题
Eclipse 编译时遇到错误could not find the main class,program will exit的解决方法
Retrieving the COM class factory for component with CLSID {00024500-0000-0000-C000-000000000046}。该文档详细列举了操作excel,word等office软件的asp .net应用部署在IIS服务器所遇到的以上异常的所有处理办法
在Myeclipse 8.5中用外带的tomcat时候,会因为JDK版本的问题出现Could not find the main class,按照上述文档的步骤就可以解决,我亲自体验过
of the Common Language Runtime (CLR) and how they relate to the Base Class Library (BCL) from the perspective of the execution environment. The author first gives an introduction to the .NET ...
Pro NET Framework with the Base Class Library,Understanding the Virtual Execution System and the Common Type System,2019
两个CADODatabse class and the CADORecordset class,这是为了在C++中更好地进行ADO数据库操作 主要的类及其函数罗列如下: The CADODatabase Class CADODatabase Open Execute GetRecordsAffected ...
Python Programming With The Java Class Libraries - A Tutorial For Building Web And Enterprise Applications With Jython.英文版
ComboBox Extending the ComboBox Class and Its Items.检查
用于企业信息化评估的系统,erp的评价、检测、评估的指导性文件 ( The Oliver Wight Class A Checklist for Business Excellence)第六版
a systematic study of the class imbalance problem.pdf
17.C++不仅仅是支持面向对象的程序设计语言; 18.学习编程最好的方法之一就是阅读源代码; 19.在任何时刻都不要认为自己手中... ... 20.请阅读《The Standard C++ Bible》(中文版:标准C++宝典),掌握C++标准;
Dynamic loading class in the java virtual machine
WIN7下运行Jar文件提示Could not find the main class
一本介绍不等式的奇书,从cachy-schwarz开始,搞物理、数学和计算机的人都应该仔细看看。
The implementation of the class-based utility to work with vectors.
Defines the class behaviors for the application.
This class defines the Service Provider Interface (<b>SPI< b>) for the CertificateFactory class.
Crown公司的I类放大器介绍,文字版英文资料。做音视频扩声的朋友可以看看。
The Service Provider Interface (SPI) for the CertPathValidator class to be implemented by security providers.