當前位置: 首頁>>代碼示例>>Java>>正文


Java InetSocketAddress.getHostString方法代碼示例

本文整理匯總了Java中java.net.InetSocketAddress.getHostString方法的典型用法代碼示例。如果您正苦於以下問題:Java InetSocketAddress.getHostString方法的具體用法?Java InetSocketAddress.getHostString怎麽用?Java InetSocketAddress.getHostString使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在java.net.InetSocketAddress的用法示例。


在下文中一共展示了InetSocketAddress.getHostString方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: init

import java.net.InetSocketAddress; //導入方法依賴的package包/類
@Before
public void init() {
    final InetSocketAddress serverAddress = dogma.dogma().activePort().get().localAddress();
    final String serverUri = "http://" + serverAddress.getHostString() + ':' + serverAddress.getPort();
    httpClient = new HttpClientBuilder(serverUri)
            .addHttpHeader(HttpHeaderNames.AUTHORIZATION, "bearer anonymous").build();

    // the default project used for unit tests
    // the default project used for unit tests
    HttpHeaders headers = HttpHeaders.of(HttpMethod.POST, "/api/v1/projects").contentType(MediaType.JSON);
    String body = "{\"name\": \"myPro\"}";
    httpClient.execute(headers, body).aggregate().join();

    // the default repository used for unit tests
    headers = HttpHeaders.of(HttpMethod.POST, "/api/v1/projects/myPro/repos").contentType(MediaType.JSON);
    body = "{\"name\": \"myRepo\"}";
    httpClient.execute(headers, body).aggregate().join();
    // default files used for unit tests
}
 
開發者ID:line,項目名稱:centraldogma,代碼行數:20,代碼來源:ContentServiceV1Test.java

示例2: getProxyURI

import java.net.InetSocketAddress; //導入方法依賴的package包/類
private URI getProxyURI(HttpRequestImpl r) {
    InetSocketAddress proxy = r.proxy(exchange.client());
    if (proxy == null) {
        return null;
    }

    // our own private scheme for proxy URLs
    // eg. proxy.http://host:port/
    String scheme = "proxy." + r.uri().getScheme();
    try {
        return new URI(scheme,
                       null,
                       proxy.getHostString(),
                       proxy.getPort(),
                       null,
                       null,
                       null);
    } catch (URISyntaxException e) {
        throw new InternalError(e);
    }
}
 
開發者ID:AdoptOpenJDK,項目名稱:openjdk-jdk10,代碼行數:22,代碼來源:AuthenticationFilter.java

示例3: decode

import java.net.InetSocketAddress; //導入方法依賴的package包/類
@Override
public void decode() {
    super.decode();
    this.offset += 16; //skip magic bytes
    InetSocketAddress address = this.getAddress();
    this.serverAddress = address.getHostString();
    this.serverPort = address.getPort();
    this.mtuSize = this.getSignedShort();
    this.clientID = this.getLong();
}
 
開發者ID:FrontierDevs,項目名稱:Jenisys3,代碼行數:11,代碼來源:OPEN_CONNECTION_REQUEST_2.java

示例4: getServerName

import java.net.InetSocketAddress; //導入方法依賴的package包/類
/**
 * If the address was created with a domain name, then return
 * the domain name string. If created with a literal IP address
 * then return null. We do this to avoid doing a reverse lookup
 * Used to populate the TLS SNI parameter. So, SNI is only set
 * when a domain name was supplied.
 */
public static String getServerName(InetSocketAddress addr) {
    String host = addr.getHostString();
    if (IPAddressUtil.textToNumericFormatV4(host) != null)
        return null;
    if (IPAddressUtil.textToNumericFormatV6(host) != null)
        return null;
    return host;
}
 
開發者ID:AdoptOpenJDK,項目名稱:openjdk-jdk10,代碼行數:16,代碼來源:Utils.java

示例5: getHostnameForSpnegoPrincipal

import java.net.InetSocketAddress; //導入方法依賴的package包/類
private static String getHostnameForSpnegoPrincipal(Configuration conf) {
  String addr = conf.getTrimmed(DFS_DATANODE_HTTP_ADDRESS_KEY, null);
  if (addr == null) {
    addr = conf.getTrimmed(DFS_DATANODE_HTTPS_ADDRESS_KEY,
                           DFS_DATANODE_HTTPS_ADDRESS_DEFAULT);
  }
  InetSocketAddress inetSocker = NetUtils.createSocketAddr(addr);
  return inetSocker.getHostString();
}
 
開發者ID:naver,項目名稱:hadoop,代碼行數:10,代碼來源:DatanodeHttpServer.java

示例6: decode

import java.net.InetSocketAddress; //導入方法依賴的package包/類
@Override
public void decode() {
    super.decode();
    this.offset += 16; //skip magic bytes
    this.serverID = this.getLong();
    InetSocketAddress address = this.getAddress();
    this.clientAddress = address.getHostString();
    this.clientPort = address.getPort();
    this.mtuSize = this.getSignedShort();
}
 
開發者ID:Rsplwe,項目名稱:Nukkit-Java9,代碼行數:11,代碼來源:OPEN_CONNECTION_REPLY_2.java

示例7: decode

import java.net.InetSocketAddress; //導入方法依賴的package包/類
@Override
public void decode() {
    super.decode();
    InetSocketAddress addr = this.getAddress();
    this.address = addr.getHostString();
    this.port = addr.getPort();

    for (int i = 0; i < 10; i++) {
        this.systemAddresses[i] = this.getAddress();
    }

    this.sendPing = this.getLong();
    this.sendPong = this.getLong();
}
 
開發者ID:CoreXDevelopment,項目名稱:CoreX,代碼行數:15,代碼來源:CLIENT_HANDSHAKE_DataPacket.java

示例8: handleInbound

import java.net.InetSocketAddress; //導入方法依賴的package包/類
public void handleInbound(DiscoveryEvent discoveryEvent) {
    Message m = discoveryEvent.getMessage();
    InetSocketAddress sender = discoveryEvent.getAddress();

    Node n = new Node(m.getNodeId(), sender.getHostString(), sender.getPort());

    if (inboundOnlyFromKnownNodes && !hasNodeHandler(n)) {
        logger.debug("=/=> (" + sender + "): inbound packet from unknown peer rejected due to config option.");
        return;
    }
    NodeHandler nodeHandler = getNodeHandler(n);

    logger.trace("===> ({}) {} [{}] {}", sender, m.getClass().getSimpleName(), nodeHandler, m);

    byte type = m.getType()[0];
    switch (type) {
        case 1:
            nodeHandler.handlePing((PingMessage) m);
            break;
        case 2:
            nodeHandler.handlePong((PongMessage) m);
            break;
        case 3:
            nodeHandler.handleFindNode((FindNodeMessage) m);
            break;
        case 4:
            nodeHandler.handleNeighbours((NeighborsMessage) m);
            break;
    }
}
 
開發者ID:talentchain,項目名稱:talchain,代碼行數:31,代碼來源:NodeManager.java

示例9: set

import java.net.InetSocketAddress; //導入方法依賴的package包/類
@Override public void set(@NonNull String key, @NonNull InetSocketAddress address,
    @NonNull SharedPreferences.Editor editor) {
  String host = null;
  if (android.os.Build.VERSION.SDK_INT >= android.os.Build.VERSION_CODES.KITKAT) {
    host = address.getHostString();
  } else {
    host = address.getHostName();
  }
  int port = address.getPort();
  editor.putString(key, host + ":" + port);
}
 
開發者ID:rogues-dev,項目名稱:superglue,代碼行數:12,代碼來源:InetSocketAddressPreferenceAdapter.java

示例10: getIP

import java.net.InetSocketAddress; //導入方法依賴的package包/類
/**
 * Returns proxy's IP address.
 * @return the IP address.
 */
public String getIP() {
  InetSocketAddress sock = (InetSocketAddress) super.address();
  return sock.getHostString();
}
 
開發者ID:braineering,項目名稱:ares,代碼行數:9,代碼來源:HttpProxy.java

示例11: authorityString

import java.net.InetSocketAddress; //導入方法依賴的package包/類
private String authorityString(InetSocketAddress addr) {
    return addr.getHostString() + ":" + addr.getPort();
}
 
開發者ID:AdoptOpenJDK,項目名稱:openjdk-jdk10,代碼行數:4,代碼來源:Http1Request.java

示例12: getRemoteAddress

import java.net.InetSocketAddress; //導入方法依賴的package包/類
private String getRemoteAddress() {
    InetSocketAddress addr = session.getRemoteAddress();
    return addr.getHostString() + ":" + addr.getPort();
}
 
開發者ID:Siketyan,項目名稱:TempMonitor,代碼行數:5,代碼來源:SocketListener.java

示例13: url

import java.net.InetSocketAddress; //導入方法依賴的package包/類
public static URL url(HttpProtocolType protocol, InetSocketAddress address,
                      String path) throws MalformedURLException {
    return new URL(protocol(protocol),
                   address.getHostString(),
                   address.getPort(), path);
}
 
開發者ID:AdoptOpenJDK,項目名稱:openjdk-jdk10,代碼行數:7,代碼來源:HTTPTest.java

示例14: getRemoteAddressString

import java.net.InetSocketAddress; //導入方法依賴的package包/類
public String getRemoteAddressString() {
	InetSocketAddress sa = getRemoteAddress();
	return sa.getHostString() + ":" + sa.getPort();
}
 
開發者ID:jc0541,項目名稱:URTorrent,代碼行數:5,代碼來源:PeerWireConnection.java

示例15: getRemoteHost

import java.net.InetSocketAddress; //導入方法依賴的package包/類
@Override
public String getRemoteHost() {
    InetSocketAddress addr = (InetSocketAddress) channel.remoteAddress();
    return addr.getHostString();
}
 
開發者ID:935237604,項目名稱:easysocket,代碼行數:6,代碼來源:NettyChannel.java


注:本文中的java.net.InetSocketAddress.getHostString方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。