本文整理了Java中org.jgroups.protocols.UDP.createMulticastSocket()
方法的一些代码示例,展示了UDP.createMulticastSocket()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。UDP.createMulticastSocket()
方法的具体详情如下:
包路径:org.jgroups.protocols.UDP
类名称:UDP
方法名:createMulticastSocket
[英]Creates a DatagramSocket when bind_port > 0. Attempts to allocate the socket with port == bind_port, and increments until it finds a valid port, or until port_range has been exceeded
[中]当绑定端口>0时创建DatagramSocket。尝试分配端口==bind_port的套接字,并递增,直到找到有效端口,或直到超过端口_范围
代码示例来源:origin: wildfly/wildfly
/**
* Creates a DatagramSocket when bind_port > 0. Attempts to allocate the socket with port == bind_port, and
* increments until it finds a valid port, or until port_range has been exceeded
* @return DatagramSocket The newly created socket
* @throws Exception
*/
protected MulticastSocket createMulticastSocketWithBindPort() throws Exception {
MulticastSocket tmp=null;
// 27-6-2003 bgooren, find available port in range (start_port, start_port+port_range)
int rcv_port=bind_port, max_port=bind_port + port_range;
while(rcv_port <= max_port) {
try {
return createMulticastSocket("jgroups.udp.sock", rcv_port);
}
catch(SocketException | SecurityException bind_ex) { // Cannot listen on this port
rcv_port++;
}
}
// Cannot listen at all, throw an Exception
if(rcv_port >= max_port + 1) // +1 due to the increment above
throw new Exception("failed to open a port in range " + bind_port + '-' + max_port);
return tmp;
}
代码示例来源:origin: wildfly/wildfly
sock=createMulticastSocketWithBindPort();
else
sock=createMulticastSocket("jgroups.udp.sock", 0);
代码示例来源:origin: org.jboss.eap/wildfly-client-all
sock=createMulticastSocketWithBindPort();
else
sock=createMulticastSocket("jgroups.udp.sock", 0);
代码示例来源:origin: org.jboss.eap/wildfly-client-all
/**
* Creates a DatagramSocket when bind_port > 0. Attempts to allocate the socket with port == bind_port, and
* increments until it finds a valid port, or until port_range has been exceeded
* @return DatagramSocket The newly created socket
* @throws Exception
*/
protected MulticastSocket createMulticastSocketWithBindPort() throws Exception {
MulticastSocket tmp=null;
// 27-6-2003 bgooren, find available port in range (start_port, start_port+port_range)
int rcv_port=bind_port, max_port=bind_port + port_range;
while(rcv_port <= max_port) {
try {
return createMulticastSocket("jgroups.udp.sock", rcv_port);
}
catch(SocketException | SecurityException bind_ex) { // Cannot listen on this port
rcv_port++;
}
}
// Cannot listen at all, throw an Exception
if(rcv_port >= max_port + 1) // +1 due to the increment above
throw new Exception("failed to open a port in range " + bind_port + '-' + max_port);
return tmp;
}
内容来源于网络,如有侵权,请联系作者删除!