本文整理汇总了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
}
示例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);
}
}
示例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();
}
示例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;
}
示例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();
}
示例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();
}
示例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();
}
示例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;
}
}
示例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);
}
示例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();
}
示例11: authorityString
import java.net.InetSocketAddress; //导入方法依赖的package包/类
private String authorityString(InetSocketAddress addr) {
return addr.getHostString() + ":" + addr.getPort();
}
示例12: getRemoteAddress
import java.net.InetSocketAddress; //导入方法依赖的package包/类
private String getRemoteAddress() {
InetSocketAddress addr = session.getRemoteAddress();
return addr.getHostString() + ":" + addr.getPort();
}
示例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);
}
示例14: getRemoteAddressString
import java.net.InetSocketAddress; //导入方法依赖的package包/类
public String getRemoteAddressString() {
InetSocketAddress sa = getRemoteAddress();
return sa.getHostString() + ":" + sa.getPort();
}
示例15: getRemoteHost
import java.net.InetSocketAddress; //导入方法依赖的package包/类
@Override
public String getRemoteHost() {
InetSocketAddress addr = (InetSocketAddress) channel.remoteAddress();
return addr.getHostString();
}