当前位置: 首页>>代码示例>>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;未经允许,请勿转载。