當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。