org.jgroups.protocols.UDP.receive()方法的使用及代码示例

x33g5p2x  于2022-02-01 转载在 其他  
字(4.1k)|赞(0)|评价(0)|浏览(190)

本文整理了Java中org.jgroups.protocols.UDP.receive()方法的一些代码示例,展示了UDP.receive()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。UDP.receive()方法的具体详情如下:
包路径:org.jgroups.protocols.UDP
类名称:UDP
方法名:receive

UDP.receive介绍

暂无

代码示例

代码示例来源:origin: apache/geode

@Override
public void receive(Address sender, byte[] data, int offset, int length) {
 if (data == null || length <= 0) { // GEODE-1596 - check for empty messages
  return;
 }
 // drop message from self; it has already been looped back up
 // (https://issues.jboss.org/browse/JGRP-1765)
 if (local_physical_addr != null && local_physical_addr.equals(sender))
  return;
 if (length - offset == 4 && data[offset] == 'p' && data[offset + 1] == 'i'
   && data[offset + 2] == 'n' && data[offset + 3] == 'g') {
  // AvailablePort check
  data[offset + 1] = 'o';
  try {
   sendToSingleMember(sender, data, offset, length);
  } catch (Exception e) {
   log.fatal("Unable to respond to available-port check", e);
  }
  return;
 }
 super.receive(sender, data, offset, length);
}

代码示例来源:origin: wildfly/wildfly

public void run() {
  final byte           receive_buf[]=new byte[66000]; // to be on the safe side (IPv6 == 65575 bytes, IPv4 = 65535)
  final DatagramPacket packet=new DatagramPacket(receive_buf, receive_buf.length);
  while(thread != null && Thread.currentThread().equals(thread)) {
    try {
      // solves Android ISSUE #24748 - DatagramPacket truncated UDP in ICS
      if(is_android)
        packet.setLength(receive_buf.length);
      receiver_socket.receive(packet);
      int len=packet.getLength();
      if(len > receive_buf.length && log.isErrorEnabled())
        log.error(Util.getMessage("SizeOfTheReceivedPacket"), len, receive_buf.length, receive_buf.length);
      receive(new IpAddress(packet.getAddress(), packet.getPort()),
          receive_buf, packet.getOffset(), len);
    }
    catch(SocketException sock_ex) {
      if(receiver_socket.isClosed()) {
        log.debug("receiver socket is closed, exception=" + sock_ex);
        break;
      }
      log.error(Util.getMessage("FailedReceivingPacket"), sock_ex);
    }
    catch(Throwable ex) {
      log.error(Util.getMessage("FailedReceivingPacket"), ex);
    }
  }
  if(log.isDebugEnabled()) log.debug(name + " thread terminated");
}

代码示例来源:origin: org.apache.geode/gemfire-core

@Override
public void receive(Address sender, byte[] data, int offset, int length, boolean copy_buffer) {
 if(data == null) return;
 // drop message from self; it has already been looped back up (https://issues.jboss.org/browse/JGRP-1765)
 if(local_physical_addr != null && local_physical_addr.equals(sender))
   return;
 if (length-offset == 4
   && data[offset] == 'p'
   && data[offset+1] == 'i'
   && data[offset+2] == 'n'
   && data[offset+3] == 'g') {
  // AvailablePort check
  data[offset+1] = 'o';
  try {
   sendToSingleMember(sender, data, offset, length);
  } catch (Exception e) {
   log.fatal("Unable to respond to available-port check", e);
  }
  return;
 }
 super.receive(sender,  data,  offset,  length, copy_buffer);
}

代码示例来源:origin: org.jgroups/com.springsource.org.jgroups

"Use the FRAG protocol and make its frag_size lower than " + receive_buf.length);
receive(local_addr, sender, data, offset, len);

代码示例来源:origin: org.jgroups/com.springsource.org.jgroups

receive(mcast_addr, sender, data, offset, len);

代码示例来源:origin: org.jboss.eap/wildfly-client-all

public void run() {
  final byte           receive_buf[]=new byte[66000]; // to be on the safe side (IPv6 == 65575 bytes, IPv4 = 65535)
  final DatagramPacket packet=new DatagramPacket(receive_buf, receive_buf.length);
  while(thread != null && Thread.currentThread().equals(thread)) {
    try {
      // solves Android ISSUE #24748 - DatagramPacket truncated UDP in ICS
      if(is_android)
        packet.setLength(receive_buf.length);
      receiver_socket.receive(packet);
      int len=packet.getLength();
      if(len > receive_buf.length && log.isErrorEnabled())
        log.error(Util.getMessage("SizeOfTheReceivedPacket"), len, receive_buf.length, receive_buf.length);
      receive(new IpAddress(packet.getAddress(), packet.getPort()),
          receive_buf, packet.getOffset(), len);
    }
    catch(SocketException sock_ex) {
      if(receiver_socket.isClosed()) {
        log.debug("receiver socket is closed, exception=" + sock_ex);
        break;
      }
      log.error(Util.getMessage("FailedReceivingPacket"), sock_ex);
    }
    catch(Throwable ex) {
      log.error(Util.getMessage("FailedReceivingPacket"), ex);
    }
  }
  if(log.isDebugEnabled()) log.debug(name + " thread terminated");
}

相关文章