@Override public OioServerSocketChannelConfig setSoTimeout(int timeout) { try { javaSocket.setSoTimeout(timeout); } catch (IOException e) { throw new ChannelException(e); } return this; }
@Override public OioServerSocketChannelConfig setSoTimeout(int timeout) { try { javaSocket.setSoTimeout(timeout); } catch (IOException e) { throw new ChannelException(e); } return this; }
/** * Starts the python script. * * @throws IOException */ public void open() throws IOException { server = new ServerSocket(0); server.setSoTimeout(50); startPython(); }
/** * 创建ServerSocket,使用自动分配端口 */ public void init() { try { socket = new ServerSocket(port, 0, InetAddress.getByAddress(new byte[]{127, 0, 0, 1})); socket.setSoTimeout(5000); port = socket.getLocalPort(); Log.d(LOG_TAG, "port " + port + " obtained"); } catch (UnknownHostException e) { Log.e(LOG_TAG, "Error initializing server", e); } catch (IOException e) { Log.e(LOG_TAG, "Error initializing server", e); } }
@Override public OioServerSocketChannelConfig setSoTimeout(int timeout) { try { javaSocket.setSoTimeout(timeout); } catch (IOException e) { throw new ChannelException(e); } return this; }
private void startPython(String tmpPath, String args) throws IOException { String pythonBinaryPath = config.getString(PythonOptions.PYTHON_BINARY_PATH); try { Runtime.getRuntime().exec(pythonBinaryPath); } catch (IOException ignored) { throw new RuntimeException(pythonBinaryPath + " does not point to a valid python binary."); } process = Runtime.getRuntime().exec(pythonBinaryPath + " -B " + tmpPath + FLINK_PYTHON_PLAN_NAME + args); new Thread(new StreamPrinter(process.getInputStream())).start(); new Thread(new StreamPrinter(process.getErrorStream())).start(); server = new ServerSocket(0); server.setSoTimeout(50); process.getOutputStream().write("plan\n".getBytes(ConfigConstants.DEFAULT_CHARSET)); process.getOutputStream().flush(); }
public NetJavaServerSocketImpl (Protocol protocol, String hostname, int port, ServerSocketHints hints) { this.protocol = protocol; // create the server socket try { // initialize server = new java.net.ServerSocket(); if (hints != null) { server.setPerformancePreferences(hints.performancePrefConnectionTime, hints.performancePrefLatency, hints.performancePrefBandwidth); server.setReuseAddress(hints.reuseAddress); server.setSoTimeout(hints.acceptTimeout); server.setReceiveBufferSize(hints.receiveBufferSize); } // and bind the server... InetSocketAddress address; if( hostname != null ) { address = new InetSocketAddress(hostname, port); } else { address = new InetSocketAddress(port); } if (hints != null) { server.bind(address, hints.backlog); } else { server.bind(address); } } catch (Exception e) { throw new GdxRuntimeException("Cannot create a server socket at port " + port + ".", e); } }
public NetJavaServerSocketImpl (Protocol protocol, String hostname, int port, ServerSocketHints hints) { this.protocol = protocol; // create the server socket try { // initialize server = new java.net.ServerSocket(); if (hints != null) { server.setPerformancePreferences(hints.performancePrefConnectionTime, hints.performancePrefLatency, hints.performancePrefBandwidth); server.setReuseAddress(hints.reuseAddress); server.setSoTimeout(hints.acceptTimeout); server.setReceiveBufferSize(hints.receiveBufferSize); } // and bind the server... InetSocketAddress address; if( hostname != null ) { address = new InetSocketAddress(hostname, port); } else { address = new InetSocketAddress(port); } if (hints != null) { server.bind(address, hints.backlog); } else { server.bind(address); } } catch (Exception e) { throw new GdxRuntimeException("Cannot create a server socket at port " + port + ".", e); } }
public void start() throws IOException { logger.debug("Starting Bootstrap Listener to communicate with Bootstrap Port {}", bootstrapPort); serverSocket = new ServerSocket(); serverSocket.bind(new InetSocketAddress("localhost", 0)); serverSocket.setSoTimeout(2000); final int localPort = serverSocket.getLocalPort(); logger.info("Started Bootstrap Listener, Listening for incoming requests on port {}", localPort); listener = new Listener(serverSocket); final Thread listenThread = new Thread(listener); listenThread.setDaemon(true); listenThread.setName("Listen to Bootstrap"); listenThread.start(); logger.debug("Notifying Bootstrap that local port is {}", localPort); sendCommand("PORT", new String[] { String.valueOf(localPort), secretKey}); }
@Signature(@Arg("timeout")) public Memory setSoTimeout(Environment env, Memory... args) throws SocketException { socket.setSoTimeout(args[0].toInteger()); return Memory.NULL; }
public Acceptor(ServerSocket serverSocket, URI uri) { socket = serverSocket; target = uri; pause.set(new CountDownLatch(0)); try { socket.setSoTimeout(ACCEPT_TIMEOUT_MILLIS); } catch (SocketException e) { e.printStackTrace(); } }
public PortForwarder(int from, int to) throws IOException { this.to = to; serverSocket = new ServerSocket(from); serverSocket.setSoTimeout(30000); this.start(); }
socket.setSoTimeout(SO_TIMEOUT); success = true; } catch (IOException e) {
try { serverSocket = createServerSocket(port); serverSocket.setSoTimeout(1000); serverSocket.setSoTimeout(1000);
socket.setSoTimeout(SO_TIMEOUT); success = true; } catch (IOException e) {
/** * 启动Greys服务端 * * @param configure 配置信息 * @throws IOException 服务器启动失败 */ public void bind(Configure configure) throws IOException { if (!isBindRef.compareAndSet(false, true)) { throw new IllegalStateException("already bind"); } try { serverSocketChannel = ServerSocketChannel.open(); selector = Selector.open(); serverSocketChannel.configureBlocking(false); serverSocketChannel.socket().setSoTimeout(configure.getConnectTimeout()); serverSocketChannel.socket().setReuseAddress(true); serverSocketChannel.register(selector, OP_ACCEPT); // 服务器挂载端口 serverSocketChannel.socket().bind(getInetSocketAddress(configure.getTargetIp(), configure.getTargetPort()), 24); logger.info("ga-server listening on network={};port={};timeout={};", configure.getTargetIp(), configure.getTargetPort(), configure.getConnectTimeout()); activeSelectorDaemon(selector, configure); } catch (IOException e) { unbind(); throw e; } }
public MockServer start() throws IOException { _server = new ServerSocket(); _server.setSoTimeout(5000); _server.bind(new InetSocketAddress("localhost", 0)); _serverSocketPort = _server.getLocalPort(); _threads.add(new EasyThread() { @Override void runQuietly() throws Exception { runServer(); } }.startThread()); return this; }
socket.setSoTimeout(SO_TIMEOUT); success = true; } catch (IOException e) {
ServerSocket serverSocket = new ServerSocket(); serverSocket.bind(new InetSocketAddress("localhost",0)); serverSocket.setSoTimeout(10*1000);
public static ServerSocket createServerSocket(final int port, final ServerSocketConfiguration config) throws IOException, KeyManagementException, UnrecoverableKeyException, NoSuchAlgorithmException, KeyStoreException, CertificateException { if (config == null) { throw new NullPointerException("Configuration may not be null."); } final SSLContext sslContext = config.createSSLContext(); final ServerSocket serverSocket; if (sslContext == null) { serverSocket = new ServerSocket(port); } else { serverSocket = sslContext.getServerSocketFactory().createServerSocket(port); ((SSLServerSocket) serverSocket).setNeedClientAuth(config.getNeedClientAuth()); } if (config.getSocketTimeout() != null) { serverSocket.setSoTimeout(config.getSocketTimeout()); } if (config.getReuseAddress() != null) { serverSocket.setReuseAddress(config.getReuseAddress()); } if (config.getReceiveBufferSize() != null) { serverSocket.setReceiveBufferSize(config.getReceiveBufferSize()); } return serverSocket; }