当前位置: 首页>>代码示例>>Java>>正文


Java InetSocketAddress.getAddress方法代码示例

本文整理汇总了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));
}
 
开发者ID:yunhaibin,项目名称:dubbox-hystrix,代码行数:24,代码来源:RpcContext.java

示例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;
}
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:27,代码来源:SctpMultiChannelImpl.java

示例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);
    }

}
 
开发者ID:lamsfoundation,项目名称:lams,代码行数:23,代码来源:ServletRequestContext.java

示例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;
}
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:27,代码来源:SctpChannelImpl.java

示例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));
}
 
开发者ID:flychao88,项目名称:dubbocloud,代码行数:24,代码来源:RpcContext.java

示例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 ));
	 }
}
 
开发者ID:BiglySoftware,项目名称:BiglyBT,代码行数:24,代码来源:VirtualServerChannelSelectorFactory.java

示例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);
}
 
开发者ID:fengchen8086,项目名称:ditb,代码行数:28,代码来源:TestTokenAuthentication.java

示例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() };
}
 
开发者ID:l294265421,项目名称:ZooKeeper,代码行数:8,代码来源:Zab1_0Test.java

示例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;
}
 
开发者ID:nucypher,项目名称:hadoop-oss,代码行数:15,代码来源:NuCypherExtUtilClient.java

示例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;
}
 
开发者ID:justor,项目名称:elasticsearch_my,代码行数:10,代码来源:TransportAddress.java

示例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;
}
 
开发者ID:dachengxi,项目名称:EatDubbo,代码行数:16,代码来源:ServerPeer.java

示例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();
}
 
开发者ID:lyy4j,项目名称:rmq4note,代码行数:9,代码来源:ChannelUtil.java

示例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);
}
 
开发者ID:mozilla-mobile,项目名称:FirefoxData-android,代码行数:16,代码来源:SchemeSocketFactoryAdaptor.java

示例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() };
}
 
开发者ID:didichuxing2,项目名称:https-github.com-apache-zookeeper,代码行数:8,代码来源:Zab1_0Test.java

示例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;
}
 
开发者ID:BiglySoftware,项目名称:BiglyBT,代码行数:15,代码来源:SocketServer.java


注:本文中的java.net.InetSocketAddress.getAddress方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。