List of usage examples for java.net InetSocketAddress InetSocketAddress
private InetSocketAddress(int port, String hostname)
From source file:com.blackducksoftware.integration.hub.global.HubProxyInfo.java
public URLConnection openConnection(final URL url) throws IOException { if (shouldUseProxyForUrl(url)) { final Proxy proxy = new Proxy(Proxy.Type.HTTP, new InetSocketAddress(host, port)); setDefaultAuthenticator();/*w w w . j a va2 s .c o m*/ return url.openConnection(proxy); } return url.openConnection(); }
From source file:org.messic.server.api.musicinfo.duckduckgoimages.MusicInfoDuckDuckGoImages.java
private Proxy getProxy() { if (this.configuration != null) { String url = (String) this.configuration.get(MessicPlugin.CONFIG_PROXY_URL); String port = (String) this.configuration.get(MessicPlugin.CONFIG_PROXY_PORT); if (url != null && port != null && url.length() > 0 && port.length() > 0) { SocketAddress addr = new InetSocketAddress(url, Integer.valueOf(port)); Proxy proxy = new Proxy(Proxy.Type.HTTP, addr); return proxy; }//from w ww. ja v a2 s . c om } return null; }
From source file:puma.application.evaluation.metrics.MetricsController.java
@RequestMapping(value = "/metrics/clear", method = RequestMethod.GET) public @ResponseBody void clear() { TimerFactory.getInstance().resetAllTimers(); // connect metrics to the Graphite server if (reporter != null) { reporter.stop();/*from ww w. j av a 2 s . co m*/ } final Graphite graphite = new Graphite(new InetSocketAddress("172.16.4.2", 2003)); reporter = GraphiteReporter.forRegistry(TimerFactory.getInstance().getMetricRegistry()) .prefixedWith("puma-application").convertRatesTo(TimeUnit.SECONDS) .convertDurationsTo(TimeUnit.MILLISECONDS).filter(MetricFilter.ALL).build(graphite); reporter.start(10, TimeUnit.SECONDS); }
From source file:fi.tut.fast.MulticastProducer.java
@Override protected void doStart() throws Exception { super.doStart(); InetAddress addr = null;// ww w. j a v a2s .c om Class addrClass; if (endpoint.getMulticastGroup() instanceof Inet4Address) { addrClass = Inet4Address.class; } else { addrClass = Inet6Address.class; } for (Enumeration<InetAddress> as = endpoint.getInterface().getInetAddresses(); as.hasMoreElements();) { InetAddress a = as.nextElement(); if (addrClass.isInstance(a)) { addr = a; } } if (addr == null) { addr = endpoint.getInterface().getInetAddresses().nextElement(); } LOG.info(String.format("Starting Producer Endpoint on interface %s (%s) ", endpoint.getInterface().getDisplayName(), addr.getHostAddress())); s = new MulticastSocket(new InetSocketAddress(addr.getHostAddress(), endpoint.getSourcePort())); s.setReuseAddress(true); s.setNetworkInterface(endpoint.getInterface()); s.setLoopbackMode(true); // s.setBroadcast(true); // s.joinGroup(endpoint.getMulticastGroup()); // s.connect(endpoint.getMulticastGroup(), endpoint.getAddress().getPort()); // s.bind(new InetSocketAddress(endpoint.getMulticastGroup(), 0)); }
From source file:com.clustercontrol.poller.impl.UdpTransportMappingImpl.java
public void sendMessage(UdpAddress targetAddress, byte[] message, TransportStateReference tmStateReference) throws java.io.IOException { InetSocketAddress targetSocketAddress = new InetSocketAddress(targetAddress.getInetAddress(), targetAddress.getPort());/*from w ww . j a v a 2 s. c o m*/ if (logger.isDebugEnabled()) { logger.debug("Sending message to " + targetAddress + " with length " + message.length + ": " + new OctetString(message).toHexString()); } DatagramSocket s = ensureSocket(); s.send(new DatagramPacket(message, message.length, targetSocketAddress)); }
From source file:com.itude.mobile.android.util.https.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 a va 2s .c om @Override 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:org.apache.hadoop.gateway.GatewayLdapDynamicGroupFuncTest.java
@BeforeClass public static void setupSuite() throws Exception { LOG_ENTER();//from w w w . j a v a2 s . c o m //appenders = NoOpAppender.setUp(); int port = setupLdap(); setupGateway(port); TestUtils.awaitPortOpen(new InetSocketAddress("localhost", port), 10000, 100); TestUtils.awaitNon404HttpStatus(new URL(serviceUrl), 10000, 100); LOG_EXIT(); }
From source file:com.pras.conn._HttpConHandler.java
private Proxy getProxy() { /**//from w w w. j ava 2 s .c o m * Connect through a Proxy */ Authenticator.setDefault(new Authenticator() { protected PasswordAuthentication getPasswordAuthentication() { return new PasswordAuthentication(PROXY_USER, PROXY_PASS.toCharArray()); } }); return new Proxy(Type.HTTP, new InetSocketAddress(PROXY_URL, PROXY_PORT)); // return Proxy.NO_PROXY; }
From source file:io.hops.leaderElection.experiments.LightWeightNameNode.java
public InetSocketAddress getNameNodeAddress() { Pattern p = Pattern.compile("^\\s*(.*?):(\\d+)\\s*$"); Matcher m = p.matcher(leaderElection.getRpcAddress()); if (m.matches()) { String host = m.group(1); int port = Integer.parseInt(m.group(2)); return new InetSocketAddress(host, port); } else {/*from ww w.j a v a 2s . c o m*/ return null; } }
From source file:com.sun.faban.driver.transport.hc3.AboveTimedSSLSocketFactory.java
public Socket createSocket(String host, int port, InetAddress localAddress, int localPort, HttpConnectionParams params) throws IOException { if (params == null) { throw new IllegalArgumentException("Parameters may not be null"); }//from w w w. ja v a 2 s . c om int timeout = params.getConnectionTimeout(); if (timeout <= 0) { return createSocket(host, port, localAddress, localPort); } else { Socket socket = new TimedSocketWrapper(sslFactory.createSocket()); InetSocketAddress endpoint = new InetSocketAddress(host, port); socket.bind(new InetSocketAddress(localAddress, localPort)); socket.connect(endpoint, timeout); return socket; } }