List of usage examples for java.net InetSocketAddress InetSocketAddress
private InetSocketAddress(int port, String hostname)
From source file:net.zorgblub.typhon.ssl.EasySSLSocketFactory.java
/** * @see org.apache.http.conn.scheme.SocketFactory#connectSocket(java.net.Socket, java.lang.String, int, * java.net.InetAddress, int, org.apache.http.params.HttpParams) *///from w w w .j av a2 s. c om public Socket connectSocket(Socket sock, String host, int port, InetAddress localAddress, int localPort, HttpParams params) throws IOException { int connTimeout = HttpConnectionParams.getConnectionTimeout(params); int soTimeout = HttpConnectionParams.getSoTimeout(params); InetSocketAddress remoteAddress = new InetSocketAddress(host, port); SSLSocket sslsock = (SSLSocket) ((sock != null) ? sock : createSocket()); if ((localAddress != null) || (localPort > 0)) { // we need to bind explicitly if (localPort < 0) { localPort = 0; // indicates "any" } InetSocketAddress isa = new InetSocketAddress(localAddress, localPort); sslsock.bind(isa); } sslsock.connect(remoteAddress, connTimeout); sslsock.setSoTimeout(soTimeout); return sslsock; }
From source file:net.sf.jinsim.UDPChannel.java
public UDPChannel(String host, int port, boolean multicast) throws IOException { this(new InetSocketAddress(host, port), multicast); }
From source file:com.vmware.photon.controller.housekeeper.helpers.dcp.TestEnvironment.java
/** * Get CloudStoreHelper created using one of the hosts in TestEnvironment. *///from w ww .j a v a 2 s . c o m public CloudStoreHelper getCloudStoreHelper() { ServiceHost host = this.getHosts()[0]; StaticServerSet serverSet = new StaticServerSet( new InetSocketAddress(host.getPreferredAddress(), host.getPort())); return new CloudStoreHelper(serverSet); }
From source file:com.nesscomputing.cache.CacheTopologyProvider.java
@Inject CacheTopologyProvider(final CacheConfiguration config, final ReadOnlyDiscoveryClient discoveryClient, @Named("cacheName") String cacheName) { this.discoveryClient = discoveryClient; this.cacheName = cacheName; List<URI> uris = config.getCacheUri(); if (uris != null) { ImmutableList.Builder<InetSocketAddress> addrBuilder = ImmutableList.builder(); for (URI uri : uris) { if ("memcache".equals(uri.getScheme())) { addrBuilder.add(new InetSocketAddress(uri.getHost(), uri.getPort())); } else { LOG.warn("Ignored uri %s due to wrong scheme", uri); }/*from ww w . ja va2 s . c o m*/ } addrs = addrBuilder.build(); LOG.info("Using configured caches: %s", addrs); } else { addrs = null; LOG.info("Using dynamically discovered caches."); } }
From source file:edu.tsinghua.lumaqq.ui.jobs.GetCustomHeadInfoJob.java
@Override protected boolean canRun() { // port/* www .j a v a 2 s. co m*/ try { conn = QQPort.CUSTOM_HEAD_INFO.create(main.getClient(), new InetSocketAddress(QQ.QQ_SERVER_DOWNLOAD_CUSTOM_HEAD, 4000), null, true); } catch (IOException e) { log.error("??"); return false; } // ?? friends = new ArrayList<Integer>(); Iterator<User> iter = ModelRegistry.getUserIterator(); while (iter.hasNext()) { User u = iter.next(); if (u.hasCustomHead) friends.add(u.qq); } // ?0 if (friends.isEmpty()) return false; return true; }
From source file:example.springdata.cassandra.util.RequiresCassandraKeyspace.java
@Override protected void before() throws Throwable { try (Socket socket = new Socket()) { socket.setTcpNoDelay(true);/* w ww. ja va 2s .c o m*/ socket.setSoLinger(true, 0); socket.connect(new InetSocketAddress(host, port), timeout); } catch (Exception e) { throw new AssumptionViolatedException( String.format("Seems as Cassandra is not running at %s:%s.", host, port), e); } Cluster cluster = Cluster.builder().addContactPoint(host).withPort(port) .withNettyOptions(new NettyOptions() { @Override public void onClusterClose(EventLoopGroup eventLoopGroup) { eventLoopGroup.shutdownGracefully(0, 0, TimeUnit.MILLISECONDS).syncUninterruptibly(); } }).build(); Session session = cluster.newSession(); try { if (requiresVersion != null) { Version cassandraReleaseVersion = CassandraVersion.getReleaseVersion(session); if (cassandraReleaseVersion.isLessThan(requiresVersion)) { throw new AssumptionViolatedException( String.format("Cassandra at %s:%s runs in Version %s but we require at least %s", host, port, cassandraReleaseVersion, requiresVersion)); } } session.execute(String.format( "CREATE KEYSPACE IF NOT EXISTS %s \n" + "WITH REPLICATION = { 'class' : 'SimpleStrategy', 'replication_factor' : 1 };", keyspaceName)); } finally { session.close(); cluster.close(); } }
From source file:pl.xsolve.verfluchter.rest.EasySSLSocketFactory.java
/** * @see org.apache.http.conn.scheme.SocketFactory#connectSocket(java.net.Socket, java.lang.String, int, * java.net.InetAddress, int, org.apache.http.params.HttpParams) *///w w w .jav a 2 s . c o m public Socket connectSocket(Socket sock, String host, int port, InetAddress localAddress, int localPort, HttpParams params) throws IOException, UnknownHostException, ConnectTimeoutException { int connTimeout = HttpConnectionParams.getConnectionTimeout(params); int soTimeout = HttpConnectionParams.getSoTimeout(params); InetSocketAddress remoteAddress = new InetSocketAddress(host, port); SSLSocket sslsock = (SSLSocket) ((sock != null) ? sock : createSocket()); if ((localAddress != null) || (localPort > 0)) { // we need to bind explicitly if (localPort < 0) { localPort = 0; // indicates "any" } InetSocketAddress isa = new InetSocketAddress(localAddress, localPort); sslsock.bind(isa); } sslsock.connect(remoteAddress, connTimeout); sslsock.setSoTimeout(soTimeout); return sslsock; }
From source file:com.juick.android.JASocketClient.java
public boolean connect(String host, int port) { try {//w ww. jav a 2s .c o m log("JASocketClient:" + name + ": new"); sock = new Socket(); sock.setSoTimeout(60000); // 1 minute timeout; to check missing pongs and drop connection sock.connect(new InetSocketAddress(host, port)); is = sock.getInputStream(); os = sock.getOutputStream(); log("connected"); return true; } catch (Throwable e) { log("connect:" + e.toString()); System.err.println(e); //e.printStackTrace(); return false; } }
From source file:net.niyonkuru.koodroid.security.EasySSLSocketFactory.java
/** * @see org.apache.http.conn.scheme.SocketFactory#connectSocket(java.net.Socket, * java.lang.String, int, java.net.InetAddress, int, * org.apache.http.params.HttpParams) *//* ww w . j a va 2s .c o m*/ @Override public Socket connectSocket(Socket sock, String host, int port, InetAddress localAddress, int localPort, HttpParams params) throws IOException, ConnectTimeoutException { int connTimeout = HttpConnectionParams.getConnectionTimeout(params); int soTimeout = HttpConnectionParams.getSoTimeout(params); InetSocketAddress remoteAddress = new InetSocketAddress(host, port); SSLSocket sslsock = (SSLSocket) ((sock != null) ? sock : createSocket()); if ((localAddress != null) || (localPort > 0)) { // we need to bind explicitly if (localPort < 0) { localPort = 0; // indicates "any" } InetSocketAddress isa = new InetSocketAddress(localAddress, localPort); sslsock.bind(isa); } sslsock.connect(remoteAddress, connTimeout); sslsock.setSoTimeout(soTimeout); return sslsock; }
From source file:org.andromda.android.net.EasySSLSocketFactory.java
/** * @see org.apache.http.conn.scheme.SocketFactory#connectSocket(java.net.Socket, * java.lang.String, int, java.net.InetAddress, int, * org.apache.http.params.HttpParams) *///from w w w . ja v a2s. c om @Override public Socket connectSocket(final Socket sock, final String host, final int port, final InetAddress localAddress, int localPort, final HttpParams params) throws IOException, UnknownHostException, ConnectTimeoutException { final int connTimeout = HttpConnectionParams.getConnectionTimeout(params); final int soTimeout = HttpConnectionParams.getSoTimeout(params); final InetSocketAddress remoteAddress = new InetSocketAddress(host, port); final SSLSocket sslsock = (SSLSocket) ((sock != null) ? sock : createSocket()); if ((localAddress != null) || (localPort > 0)) { // we need to bind explicitly if (localPort < 0) { localPort = 0; // indicates "any" } final InetSocketAddress isa = new InetSocketAddress(localAddress, localPort); sslsock.bind(isa); } sslsock.connect(remoteAddress, connTimeout); sslsock.setSoTimeout(soTimeout); return sslsock; }