当前位置: 首页>>代码示例>>Java>>正文


Java SocketAddress.equals方法代码示例

本文整理汇总了Java中java.net.SocketAddress.equals方法的典型用法代码示例。如果您正苦于以下问题:Java SocketAddress.equals方法的具体用法?Java SocketAddress.equals怎么用?Java SocketAddress.equals使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在java.net.SocketAddress的用法示例。


在下文中一共展示了SocketAddress.equals方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: closeConnectionAsync

import java.net.SocketAddress; //导入方法依赖的package包/类
@Override
public CompletionStage<ClusterConnectionReport> closeConnectionAsync(
    SocketAddress connection, CloseType type) {

  for (BoundNode node : this.getNodes()) {
    // identify the node that has the connection and close it with that node.
    for (SocketAddress address : node.getConnections().getConnections()) {
      if (connection.equals(address)) {
        return node.closeConnectionAsync(address, type)
            .thenApply(NodeConnectionReport::getRootReport);
      }
    }
  }

  CompletableFuture<ClusterConnectionReport> failedFuture = new CompletableFuture<>();
  failedFuture.completeExceptionally(new IllegalArgumentException("Not found"));
  return failedFuture;
}
 
开发者ID:datastax,项目名称:simulacron,代码行数:19,代码来源:BoundCluster.java

示例2: closeConnectionAsync

import java.net.SocketAddress; //导入方法依赖的package包/类
@Override
public CompletionStage<DataCenterConnectionReport> closeConnectionAsync(
    SocketAddress connection, CloseType type) {

  for (BoundNode node : this.getNodes()) {
    // identify the node that has the connection and close it with that node.
    for (SocketAddress address : node.getConnections().getConnections()) {
      if (connection.equals(address)) {
        return node.closeConnectionAsync(address, type)
            .thenApply(n -> n.getRootReport().getDataCenters().iterator().next());
      }
    }
  }

  CompletableFuture<DataCenterConnectionReport> failedFuture = new CompletableFuture<>();
  failedFuture.completeExceptionally(new IllegalArgumentException("Not found"));
  return failedFuture;
}
 
开发者ID:datastax,项目名称:simulacron,代码行数:19,代码来源:BoundDataCenter.java

示例3: run

import java.net.SocketAddress; //导入方法依赖的package包/类
@Override
public void run() {
    try {
        ByteBuffer bb = ByteBuffer.allocateDirect(12);
        bb.clear();
        // Only one clear. The buffer will be full after
        // the first receive, but it should still block
        // and receive and discard the next two
        int numberReceived = 0;
        while (!Thread.interrupted()) {
            SocketAddress sa;
            try {
                sa = dc.receive(bb);
            } catch (ClosedByInterruptException cbie) {
                // Expected
                log.println("Took expected exit");
                // Verify that enough packets were received
                if (numberReceived != 3)
                    throw new RuntimeException("Failed: Too few datagrams");
                break;
            }
            if (sa != null) {
                log.println("Client: " + sa);
                // Check client address so as not to count stray packets
                if (sa.equals(clientAddress)) {
                    showBuffer("RECV", bb);
                    numberReceived++;
                }
                if (numberReceived > 3)
                    throw new RuntimeException("Failed: Too many datagrams");
                sa = null;
            }
        }
    } catch (Exception ex) {
        e = ex;
    } finally {
        try { dc.close(); } catch (IOException ignore) { }
    }
}
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:40,代码来源:EmptyBuffer.java


注:本文中的java.net.SocketAddress.equals方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。