List of usage examples for java.net InetSocketAddress InetSocketAddress
private InetSocketAddress(int port, String hostname)
From source file:io.netlibs.bgp.config.nodes.ClientPortConfigurationDecorator.java
@Override public InetSocketAddress getRemoteAddress() { InetSocketAddress sockAddr = decorated.getRemoteAddress(); if (sockAddr.getPort() == 0) sockAddr = new InetSocketAddress(sockAddr.getAddress(), getDefaultPort()); return sockAddr; }
From source file:io.netlibs.bgp.config.nodes.ServerPortConfigurationDecorator.java
@Override public InetSocketAddress getListenAddress() { InetSocketAddress sockAddr = decorated.getListenAddress(); if (sockAddr.getPort() == 0) sockAddr = new InetSocketAddress(sockAddr.getAddress(), getDefaultPort()); return sockAddr; }
From source file:mdretrieval.FileFetcher.java
public static InputStream fetchFileFromUrl(String urlString) { InputStream inputStream = null; Proxy proxy = ServerConstants.isProxyEnabled ? new Proxy(Proxy.Type.HTTP, new InetSocketAddress(ServerConstants.hostname, ServerConstants.port)) : Proxy.NO_PROXY;//from w w w.ja v a 2 s . c o m URL url; try { url = new URL(urlString); url.openConnection(); if (proxy != Proxy.NO_PROXY && proxy.type() != Proxy.Type.DIRECT) { inputStream = url.openConnection(proxy).getInputStream(); } else { inputStream = url.openConnection().getInputStream(); } } catch (MalformedURLException e) { GUIrefs.displayAlert("Invalid URL " + urlString + "- \\n malformed expression"); e.printStackTrace(); inputStream = null; } catch (IOException ioe) { GUIrefs.displayAlert("Cannot read from " + StringUtilities.escapeQuotes(urlString) + "- IOException"); ioe.printStackTrace(); inputStream = null; } return inputStream; }
From source file:com.metratech.metanga.api.impl.ClientHttpRequestFactorySelector.java
public static ClientHttpRequestFactory getRequestFactory() { Properties properties = System.getProperties(); String proxyHost = properties.getProperty("http.proxyHost"); int proxyPort = properties.containsKey("http.proxyPort") ? Integer.valueOf(properties.getProperty("http.proxyPort")) : 80;//from ww w.j a v a2 s . c om if (HTTP_COMPONENTS_AVAILABLE) { return HttpComponentsClientRequestFactoryCreator.createRequestFactory(proxyHost, proxyPort); } else { SimpleClientHttpRequestFactory requestFactory = new SimpleClientHttpRequestFactory(); if (proxyHost != null) { requestFactory.setProxy(new Proxy(Proxy.Type.HTTP, new InetSocketAddress(proxyHost, proxyPort))); } return requestFactory; } }
From source file:ca.viaware.dlna.upnp.http.UpnpHttpServer.java
public UpnpHttpServer() throws IOException { JSONObject config = SettingsManager.getServerConfig().getJSONObject("http"); this.server = HttpServer.create(new InetSocketAddress(config.getString("host"), config.getInt("port")), 8); }
From source file:com.walmart.gatling.MonitoringConfiguration.java
@Bean public Graphite graphite(@Value("${graphite.host}") String graphiteHost, @Value("${graphite.port}") int graphitePort) { return new Graphite(new InetSocketAddress(graphiteHost, graphitePort)); }
From source file:org.apache.mina.springrpc.DefaultMinaRequestExecutorTest.java
@Test public void connect() { IoConnector connector = EasyMock.createMock(IoConnector.class); MinaClientConfiguration configuration = new StaticConfiguration(); InetSocketAddress socketAddress = new InetSocketAddress(configuration.getHostName(), configuration.getPort());/* w w w . j a v a2s . c om*/ ResultReceiver resultReceiver = EasyMock.createMock(ResultReceiver.class); resultReceiver.interrupt(); EasyMock.expectLastCall().asStub(); EasyMock.expect(connector.connect(socketAddress)).andThrow(new RuntimeException("server crashed")); ConnectFuture connectFuture = EasyMock.createMock(ConnectFuture.class); EasyMock.expect(connector.connect(socketAddress)).andReturn(connectFuture); EasyMock.expect(connectFuture.awaitUninterruptibly()).andReturn(connectFuture); IoSession session = EasyMock.createMock(IoSession.class); EasyMock.expect(connectFuture.getSession()).andReturn(session); Object[] mocks = new Object[] { resultReceiver, connector, connectFuture, session }; EasyMock.replay(mocks); DefaultMinaRequestExecutor executor = new DefaultMinaRequestExecutor(); executor.setMinaClientConfiguration(configuration); executor.setConnector(connector); executor.setResultReceiver(resultReceiver); executor.connect(); EasyMock.verify(mocks); }
From source file:com.mirth.connect.connectors.tcp.SocketUtil.java
public static void connectSocket(Socket socket, String host, int port, int timeout) throws UnknownHostException, IOException { socket.connect(new InetSocketAddress(InetAddress.getByName(TcpUtil.getFixedHost(host)), port), timeout); }
From source file:com.btmatthews.springboot.memcached.MemcachedAutoConfiguration.java
@Bean public MemcachedClient memcachedClient() throws IOException { final List<InetSocketAddress> addresses = new ArrayList<InetSocketAddress>(); final String servers = environment.getProperty("memcached.servers"); if (StringUtils.isEmpty(servers)) { addresses.add(new InetSocketAddress(LOCALHOST, DEFAULT_PORT)); } else {/*from ww w . jav a 2 s . com*/ for (final String server : servers.split(",")) { final int colon = server.indexOf(":"); if (colon == -1) { addresses.add(new InetSocketAddress(server, DEFAULT_PORT)); } else { final int port = Integer.parseInt(server.substring(colon + 1)); addresses.add(new InetSocketAddress(server.substring(0, colon), port)); } } } return new MemcachedClient(addresses); }
From source file:de.codecentric.batch.metrics.GraphiteMetricsExporter.java
public GraphiteMetricsExporter(MetricRegistry metricRegistry, final MetricReader metricReader, String server, Integer port, String environment) { Graphite graphite = new Graphite(new InetSocketAddress(server, port)); MetricFilter filter = new MetricFilter() { @Override//w ww .j ava2 s .c om public boolean matches(String name, Metric metric) { org.springframework.boot.actuate.metrics.Metric<?> bootMetric = metricReader.findOne(name); if (bootMetric.getTimestamp().after(lastExport)) { return true; } return false; } }; reporter = GraphiteReporter.forRegistry(metricRegistry).prefixedWith(environment) .convertRatesTo(TimeUnit.SECONDS).convertDurationsTo(TimeUnit.MILLISECONDS).filter(filter) .build(graphite); }