List of usage examples for javax.net ServerSocketFactory getDefault
public static ServerSocketFactory getDefault()
From source file:io.github.kitarek.elasthttpd.server.networking.HttpConfiguredServerSocket.java
private static ServerSocket createServerSocketUnchecked(final SocketConfiguration socketConfiguration) throws IOException { ServerSocketFactory serverSocketFactory = ServerSocketFactory.getDefault(); final ServerSocket serverSocket = serverSocketFactory.createServerSocket( socketConfiguration.getListeningPort(), socketConfiguration.getConnectionsToAcceptQueueSize(), socketConfiguration.getListeningAddress()); setSocketReceiveBufferSizeWhenProvided(socketConfiguration, serverSocket); setSocketReuseAddress(socketConfiguration, serverSocket); return serverSocket; }
From source file:com.cloudant.tests.util.SimpleHttpServer.java
public SimpleHttpServer(ServerSocketFactory ssf) { this.ssf = (ssf == null) ? ServerSocketFactory.getDefault() : ssf; }
From source file:zipkin.execjar.ExecJarRule.java
/** Lazy-chooses a server port, or returns the port the server started with */ public synchronized int port() throws IOException { if (port != null) return port; try (ServerSocket socket = ServerSocketFactory.getDefault().createServerSocket(0)) { return (this.port = socket.getLocalPort()); }/*from w ww .j a va 2 s . c o m*/ }
From source file:com.googlecode.jsonrpc4j.spring.CompositeJsonStreamServiceExporter.java
/** * {@inheritDoc}/* w w w . j a v a 2 s .c om*/ */ protected void exportService() throws Exception { // export // create a stream server if needed if (streamServer == null) { // make sure we have a factory if (serverSocketFactory == null) { serverSocketFactory = ServerSocketFactory.getDefault(); } // create server socket ServerSocket serverSocket = serverSocketFactory.createServerSocket(port, backlog, InetAddress.getByName(hostName)); // create the stream server streamServer = new StreamServer(getJsonRpcServer(), maxThreads, serverSocket); streamServer.setMaxClientErrors(maxClientErrors); } // start it streamServer.start(); }
From source file:com.asksunny.tool.RemoteDataStreamer.java
public void receive() throws Exception { try (ServerSocket server = ServerSocketFactory.getDefault().createServerSocket(getPort()); Socket client = server.accept(); InputStream in = client.getInputStream(); FileOutputStream fout = new FileOutputStream(getFilePath())) { StreamCopier.copy(in, fout);// ww w . j av a 2 s . c o m } }
From source file:com.googlecode.jsonrpc4j.spring.JsonStreamServiceExporter.java
/** * {@inheritDoc}//from w ww . j ava2 s. c o m */ @Override protected void exportService() throws Exception { // create a stream server if needed if (streamServer == null) { // make sure we have a factory if (serverSocketFactory == null) { serverSocketFactory = ServerSocketFactory.getDefault(); } // create server socket ServerSocket serverSocket = serverSocketFactory.createServerSocket(port, backlog, InetAddress.getByName(hostName)); // create the stream server streamServer = new StreamServer(getJsonRpcServer(), maxThreads, serverSocket); streamServer.setMaxClientErrors(maxClientErrors); } // start it streamServer.start(); }
From source file:com.asksunny.tool.RemoteDataStreamer.java
public void receiveCompress() throws Exception { try (ServerSocket server = ServerSocketFactory.getDefault().createServerSocket(getPort()); Socket client = server.accept(); InputStream in = client.getInputStream(); GZIPInputStream gin = new GZIPInputStream(in); FileOutputStream fout = new FileOutputStream(getFilePath())) { StreamCopier.copy(gin, fout);//from w w w .ja va 2s . co m } }
From source file:com.twosigma.beakerx.kernel.MagicKernelManager.java
private void initClientServer() { this.clientServer = new ClientServer(port, GatewayServer.defaultAddress(), pythonPort, GatewayServer.defaultAddress(), GatewayServer.DEFAULT_CONNECT_TIMEOUT, GatewayServer.DEFAULT_READ_TIMEOUT, ServerSocketFactory.getDefault(), SocketFactory.getDefault(), null);/* w w w .j ava2 s . c o m*/ }
From source file:it.jnrpe.server.CBindingThread.java
private void init() throws IOException, KeyManagementException, KeyStoreException, CertificateException, UnrecoverableKeyException { InetAddress addr = InetAddress.getByName(m_Binding.getIP()); ServerSocketFactory sf = null; if (m_Binding.useSSL()) sf = getSSLSocketFactory(m_Binding.getKeyStoreFile(), m_Binding.getKeyStorePassword(), "JKS"); else// ww w .java2 s . c om sf = ServerSocketFactory.getDefault(); m_serverSocket = sf.createServerSocket(m_Binding.getPort(), 0, addr); //m_serverSocket.setSoTimeout(10000); //Ten seconds timeout added by oriol.lopez if (m_serverSocket instanceof SSLServerSocket) ((SSLServerSocket) m_serverSocket) .setEnabledCipherSuites(((SSLServerSocket) m_serverSocket).getSupportedCipherSuites()); // Init the thread factory m_threadFactory = new CThreadFactory(m_Binding.getThreadFactoryConfig()); }
From source file:com.apporiented.hermesftp.cmd.PassiveModeSocketProvider.java
/** * Creates the server socket that accepts the data connection. * /* ww w . ja v a2 s . c o m*/ * @param localIp The local IP address. * @param port The port. * @return The server socket. * @throws IOException Error on creating server socket. */ private ServerSocket createServerSocket(InetAddress localIp, int port) throws IOException { ServerSocket sock; Boolean dataProtection = (Boolean) ctx.getAttribute(FtpConstants.ATTR_DATA_PROT); boolean ssl = dataProtection != null && dataProtection; if (ssl) { SSLServerSocketFactory factory = ctx.getOptions().getSslContext().getServerSocketFactory(); SSLServerSocket sslServerSocket = (SSLServerSocket) factory.createServerSocket(port, 1, localIp); sslServerSocket.setUseClientMode(false); enableCipherSuites(sslServerSocket); sock = sslServerSocket; } else { sock = ServerSocketFactory.getDefault().createServerSocket(port, 1, localIp); } sock.setSoTimeout(DATA_CHANNEL_TIMEOUT); return sock; }