Package java.net

Examples of java.net.ServerSocket.accept()


            SocketAddress theAddress = serverSocket.getLocalSocketAddress();

            // make a connection to the server, then close the server
            Socket theSocket = new Socket();
            theSocket.connect(theAddress);
            Socket stillActiveSocket = serverSocket.accept();
            serverSocket.close();

            // now try to rebind the server which should fail with
            // setReuseAddress to false. On windows platforms the bind is
            // allowed even then reUseAddress is false so our test uses
View Full Code Here


            theAddress = serverSocket.getLocalSocketAddress();

            // make a connection to the server, then close the server
            theSocket = new Socket();
            theSocket.connect(theAddress);
            stillActiveSocket = serverSocket.accept();
            serverSocket.close();

            // now try to rebind the server which should pass with
            // setReuseAddress to true
            try {
View Full Code Here

            theAddress = serverSocket.getLocalSocketAddress();

            // make a connection to the server, then close the server
            theSocket = new Socket();
            theSocket.connect(theAddress);
            stillActiveSocket = serverSocket.accept();
            serverSocket.close();

            // now try to rebind the server which should pass
            try {
                serverSocket = new ServerSocket();
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

        // Simple read/write test over the IO streams
        final ServerSocket pingServer = new ServerSocket(0);
        Runnable runnable = new Runnable() {
            public void run() {
                try {
                    Socket worker = pingServer.accept();
                    pingServer.close();
                    InputStream in = worker.getInputStream();
                    in.read();
                    OutputStream out = worker.getOutputStream();
                    out.write(new byte[42]);
View Full Code Here

     */
    public void test_isBound() throws IOException {
        ServerSocket server = new ServerSocket(0);
        Socket client = new Socket(InetAddress.getLocalHost(), server
                .getLocalPort());
        Socket worker = server.accept();

        assertTrue("Socket indicated  not bound when it should be (1)", client
                .isBound());
        worker.close();
        client.close();
View Full Code Here

        server = new ServerSocket();
        server.bind(new InetSocketAddress(InetAddress.getLocalHost(), 0));
        InetSocketAddress boundAddress = new InetSocketAddress(server
                .getInetAddress(), server.getLocalPort());
        client.connect(boundAddress);
        worker = server.accept();
        assertTrue("Socket indicated not bound when it should be (2)", client
                .isBound());
        worker.close();
        client.close();
        server.close();
View Full Code Here

     */
    public void test_isClosed() throws IOException {
        ServerSocket server = new ServerSocket(0);
        Socket client = new Socket(InetAddress.getLocalHost(), server
                .getLocalPort());
        Socket worker = server.accept();

        // validate isClosed returns expected values
        assertFalse("Socket should indicate it is not closed(1):", client
                .isClosed());
        client.close();
View Full Code Here

     */
    public void test_isConnected() throws IOException {
        ServerSocket server = new ServerSocket(0);
        Socket client = new Socket(InetAddress.getLocalHost(), server
                .getLocalPort());
        Socket worker = server.accept();

        assertTrue("Socket indicated  not connected when it should be", client
                .isConnected());
        client.close();
        worker.close();
View Full Code Here

        server = new ServerSocket();
        server.bind(theAddress);
        InetSocketAddress boundAddress = new InetSocketAddress(server
                .getInetAddress(), server.getLocalPort());
        client.connect(boundAddress);
        worker = server.accept();
        assertTrue("Socket indicated  not connected when it should be", client
                .isConnected());
        client.close();
        worker.close();
        server.close();
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.