本文整理汇总了Java中java.net.InetSocketAddress.getAddress方法的典型用法代码示例。如果您正苦于以下问题:Java InetSocketAddress.getAddress方法的具体用法?Java InetSocketAddress.getAddress怎么用?Java InetSocketAddress.getAddress使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类java.net.InetSocketAddress
的用法示例。
在下文中一共展示了InetSocketAddress.getAddress方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: isProviderSide
import java.net.InetSocketAddress; //导入方法依赖的package包/类
/**
* is provider side.
*
* @return provider side.
*/
public boolean isProviderSide() {
URL url = getUrl();
if (url == null) {
return false;
}
InetSocketAddress address = getRemoteAddress();
if (address == null) {
return false;
}
String host;
if (address.getAddress() == null) {
host = address.getHostName();
} else {
host = address.getAddress().getHostAddress();
}
return url.getPort() != address.getPort() ||
! NetUtils.filterLocalHost(url.getIp()).equals(NetUtils.filterLocalHost(host));
}
示例2: sendFromNativeBuffer
import java.net.InetSocketAddress; //导入方法依赖的package包/类
private int sendFromNativeBuffer(int fd,
ByteBuffer bb,
SocketAddress target,
int assocId,
int streamNumber,
boolean unordered,
int ppid)
throws IOException {
InetAddress addr = null; // no preferred address
int port = 0;
if (target != null) {
InetSocketAddress isa = Net.checkAddress(target);
addr = isa.getAddress();
port = isa.getPort();
}
int pos = bb.position();
int lim = bb.limit();
assert (pos <= lim);
int rem = (pos <= lim ? lim - pos : 0);
int written = send0(fd, ((DirectBuffer)bb).address() + pos, rem, addr,
port, assocId, streamNumber, unordered, ppid);
if (written > 0)
bb.position(pos + written);
return written;
}
示例3: displayStackTraces
import java.net.InetSocketAddress; //导入方法依赖的package包/类
public boolean displayStackTraces() {
ServletStackTraces mode = deployment.getDeploymentInfo().getServletStackTraces();
if (mode == ServletStackTraces.NONE) {
return false;
} else if (mode == ServletStackTraces.ALL) {
return true;
} else {
InetSocketAddress localAddress = getExchange().getSourceAddress();
if(localAddress == null) {
return false;
}
InetAddress address = localAddress.getAddress();
if(address == null) {
return false;
}
if(!address.isLoopbackAddress()) {
return false;
}
return !getExchange().getRequestHeaders().contains(Headers.X_FORWARDED_FOR);
}
}
示例4: sendFromNativeBuffer
import java.net.InetSocketAddress; //导入方法依赖的package包/类
private int sendFromNativeBuffer(int fd,
ByteBuffer bb,
SocketAddress target,
int streamNumber,
boolean unordered,
int ppid)
throws IOException {
InetAddress addr = null; // no preferred address
int port = 0;
if (target != null) {
InetSocketAddress isa = Net.checkAddress(target);
addr = isa.getAddress();
port = isa.getPort();
}
int pos = bb.position();
int lim = bb.limit();
assert (pos <= lim);
int rem = (pos <= lim ? lim - pos : 0);
int written = send0(fd, ((DirectBuffer)bb).address() + pos, rem, addr,
port, -1 /*121*/, streamNumber, unordered, ppid);
if (written > 0)
bb.position(pos + written);
return written;
}
示例5: isConsumerSide
import java.net.InetSocketAddress; //导入方法依赖的package包/类
/**
* is consumer side.
*
* @return consumer side.
*/
public boolean isConsumerSide() {
URL url = getUrl();
if (url == null) {
return false;
}
InetSocketAddress address = getRemoteAddress();
if (address == null) {
return false;
}
String host;
if (address.getAddress() == null) {
host = address.getHostName();
} else {
host = address.getAddress().getHostAddress();
}
return url.getPort() == address.getPort() &&
NetUtils.filterLocalHost(url.getIp()).equals(NetUtils.filterLocalHost(host));
}
示例6: createTest
import java.net.InetSocketAddress; //导入方法依赖的package包/类
public static VirtualServerChannelSelector
createTest(
InetSocketAddress bind_address,
int so_rcvbuf_size,
VirtualServerChannelSelector.SelectListener listener )
{
// test param to allow multiple ports to be created
int range = COConfigurationManager.getIntParameter( "TCP.Listen.Port.Range", -1 );
if ( range == -1 ){
return( createBlocking( bind_address, so_rcvbuf_size, listener ));
}else{
return( new VirtualNonBlockingServerChannelSelector(
bind_address.getAddress(),
bind_address.getPort(),
range,
so_rcvbuf_size, listener ));
}
}
示例7: TokenServer
import java.net.InetSocketAddress; //导入方法依赖的package包/类
public TokenServer(Configuration conf) throws IOException {
this.conf = conf;
this.startcode = EnvironmentEdgeManager.currentTime();
// Server to handle client requests.
String hostname =
Strings.domainNamePointerToHostName(DNS.getDefaultHost("default", "default"));
int port = 0;
// Creation of an ISA will force a resolve.
InetSocketAddress initialIsa = new InetSocketAddress(hostname, port);
if (initialIsa.getAddress() == null) {
throw new IllegalArgumentException("Failed resolve of " + initialIsa);
}
final List<BlockingServiceAndInterface> sai =
new ArrayList<BlockingServiceAndInterface>(1);
BlockingService service =
AuthenticationProtos.AuthenticationService.newReflectiveBlockingService(this);
sai.add(new BlockingServiceAndInterface(service,
AuthenticationProtos.AuthenticationService.BlockingInterface.class));
this.rpcServer =
new RpcServer(this, "tokenServer", sai, initialIsa, conf, new FifoRpcScheduler(conf, 1));
InetSocketAddress address = rpcServer.getListenerAddress();
if (address == null) {
throw new IOException("Listener channel is closed");
}
this.isa = address;
this.sleeper = new Sleeper(1000, this);
}
示例8: getSocketPair
import java.net.InetSocketAddress; //导入方法依赖的package包/类
static Socket[] getSocketPair() throws IOException {
ServerSocket ss = new ServerSocket();
ss.bind(null);
InetSocketAddress endPoint = (InetSocketAddress) ss.getLocalSocketAddress();
Socket s = new Socket(endPoint.getAddress(), endPoint.getPort());
return new Socket[] { s, ss.accept() };
}
示例9: isLocalAddress
import java.net.InetSocketAddress; //导入方法依赖的package包/类
public static boolean isLocalAddress(InetSocketAddress targetAddr) {
InetAddress addr = targetAddr.getAddress();
Boolean cached = localAddrMap.get(addr.getHostAddress());
if (cached != null) {
LOG.trace("Address {} is {} local", targetAddr, (cached ? "" : "not"));
return cached;
}
boolean local = NetUtils.isLocalAddress(addr);
LOG.trace("Address {} is {} local", targetAddr, (local ? "" : "not"));
localAddrMap.put(addr.getHostAddress(), local);
return local;
}
示例10: TransportAddress
import java.net.InetSocketAddress; //导入方法依赖的package包/类
public TransportAddress(InetSocketAddress address) {
if (address == null) {
throw new IllegalArgumentException("InetSocketAddress must not be null");
}
if (address.getAddress() == null) {
throw new IllegalArgumentException("Address must be resolved but wasn't - InetSocketAddress#getAddress() returned null");
}
this.address = address;
}
示例11: getChannel
import java.net.InetSocketAddress; //导入方法依赖的package包/类
@Override
public Channel getChannel(InetSocketAddress remoteAddress) {
String host = remoteAddress.getAddress() != null ? remoteAddress.getAddress().getHostAddress() : remoteAddress.getHostName();
int port = remoteAddress.getPort();
Channel channel = super.getChannel(remoteAddress);
if (channel == null) {
for (Map.Entry<URL, Client> entry : clients.entrySet()) {
URL url = entry.getKey();
if (url.getIp().equals(host) && url.getPort() == port) {
return entry.getValue();
}
}
}
return channel;
}
示例12: getRemoteIp
import java.net.InetSocketAddress; //导入方法依赖的package包/类
public static String getRemoteIp(Channel channel) {
InetSocketAddress inetSocketAddress = (InetSocketAddress) channel.remoteAddress();
if (inetSocketAddress == null) {
return "";
}
final InetAddress inetAddr = inetSocketAddress.getAddress();
return inetAddr != null ? inetAddr.getHostAddress() : inetSocketAddress.getHostName();
}
示例13: connectSocket
import java.net.InetSocketAddress; //导入方法依赖的package包/类
public Socket connectSocket(
final Socket sock,
final InetSocketAddress remoteAddress,
final InetSocketAddress localAddress,
final HttpParams params) throws IOException, UnknownHostException, ConnectTimeoutException {
final String host = remoteAddress.getHostName();
final int port = remoteAddress.getPort();
InetAddress local = null;
int localPort = 0;
if (localAddress != null) {
local = localAddress.getAddress();
localPort = localAddress.getPort();
}
return this.factory.connectSocket(sock, host, port, local, localPort, params);
}
示例14: getSocketPair
import java.net.InetSocketAddress; //导入方法依赖的package包/类
static Socket[] getSocketPair() throws IOException {
ServerSocket ss =
new ServerSocket(0, 50, InetAddress.getByName("127.0.0.1"));
InetSocketAddress endPoint = (InetSocketAddress) ss.getLocalSocketAddress();
Socket s = new Socket(endPoint.getAddress(), endPoint.getPort());
return new Socket[] { s, ss.accept() };
}
示例15: isAllowed
import java.net.InetSocketAddress; //导入方法依赖的package包/类
/**
* check that the specified host/ip is allowed
* @param addr
* @return
*/
private boolean isAllowed(InetSocketAddress addr) {
InetAddress address = addr.getAddress();
if( checkHost(address.getHostAddress()) )
return true;
else if( checkHost(address.getHostName()))
return true;
else
return false;
}