Package java.net

Examples of java.net.ServerSocket.accept()


        while (keepRunning) {
          Socket socket = null;

          try {
            socket = serverSocket.accept();
          } catch (InterruptedIOException e) {
            // timeout occurred, so just loop
          } catch (SocketException e) {
            getLogger().error(
              "exception accepting socket, shutting down server socket.", e);
View Full Code Here


    {
        System.out.println("MockServer listening on port " + port);
        System.out.println("Output file = " + responseFile);

        ServerSocket serverSocket = new ServerSocket(port);
        Socket incoming = serverSocket.accept();
//        System.out.println("Got the socket " + incoming);
        InputStream inputStream = incoming.getInputStream();

        InputStreamReader inputStreamReader =
            new InputStreamReader(inputStream);
View Full Code Here

            // the data connection.  It may be desirable to let this be a
            // separately configurable value.  In any case, we really want
            // to allow preventing the accept from blocking indefinitely.
            if (__dataTimeout >= 0)
                server.setSoTimeout(__dataTimeout);
            socket = server.accept();
            server.close();
        }
        else
        { // We must be in PASSIVE_LOCAL_DATA_CONNECTION_MODE
View Full Code Here

        _output_.write(Integer.toString(server.getLocalPort()).getBytes());
        _output_.write('\0');
        _output_.flush();

        socket = server.accept();
        server.close();

        if (isRemoteVerificationEnabled() && !verifyRemote(socket))
        {
            socket.close();
View Full Code Here

        try {
            // Set the timeout to 1ms as all we care about is if it throws an
            // SSLException on accept.
            socket.setSoTimeout(1);

            socket.accept();
            // Will never get here - no client can connect to an unbound port
        } catch (SSLException ssle) {
            // SSL configuration is invalid. Possibly cert doesn't match ciphers
            IOException ioe = new IOException(sm.getString(
                    "jsse.invalid_ssl_conf", ssle.getMessage()));
View Full Code Here

  {
    ConnectionInfo result = new ConnectionInfo();
    ServerSocket serverSocket = new ServerSocket(clientPort);
    serverSocket.setReuseAddress(true);
    log("Waiting for connections on port " + clientPort);
    Socket socket = serverSocket.accept();
    result.setSocket(socket);
   
    return result;
  }
View Full Code Here

                Socket socket = null;
                StringBuilder command = new StringBuilder();
                try {
                    InputStream stream;
                    try {
                        socket = serverSocket.accept();
                        socket.setSoTimeout(10 * 1000)// Ten seconds
                        stream = socket.getInputStream();
                    } catch (AccessControlException ace) {
                        log.warn("StandardServer.accept security exception: "
                                + ace.getMessage(), ace);
View Full Code Here

            while (running)
            {
                try
                {
                    // Listen on main socket
                    Socket clientSocket = mainSocket.accept();
                    if (running)
                    {
                        // Pass request to new proxy thread
                        Proxy thd = (Proxy) proxyClass.newInstance();
                        thd.configure(clientSocket, target);
View Full Code Here

    public void test_socket_accept_Blocking_NotBound() throws IOException {
        // regression test for Harmony-748      
        ServerSocket gotSocket = serverChannel.socket();
        serverChannel.configureBlocking(true);
        try {
            gotSocket.accept();
            fail("Should throw an IllegalBlockingModeException");
        } catch (IllegalBlockingModeException e) {
            // expected
        }       
        serverChannel.close();
View Full Code Here

        } catch (IllegalBlockingModeException e) {
            // expected
        }       
        serverChannel.close();
        try {
            gotSocket.accept();
            fail("Should throw an IllegalBlockingModeException");
        } catch (IllegalBlockingModeException e) {
            // expected
        }    
    }
View Full Code Here

TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.