Package java.net

Examples of java.net.Socket.shutdownOutput()


        int data;
        while ((data = requestMsgInStream.read()) != -1) {
            outStream.write(data);
        }
        outStream.flush();
        socket.shutdownOutput();
        BufferedReader reader = new BufferedReader(new InputStreamReader(socket
                .getInputStream()));
        StringBuffer sb = new StringBuffer();

        String response = reader.readLine();
View Full Code Here


        }
        fis.close();
        sendLine("bsh.prompt=\"bsh % \";",os);// Reset for other users
        os.flush();
        os.close();
        sock.shutdownOutput(); // Tell server that we are done
    }

    private static void sendLine( String line, OutputStream outPipe )
    throws IOException
    {
View Full Code Here

                    key.selected(OP_READ);
                }
            }
            if (how == ShutdownType.WRITE || how == ShutdownType.BOTH) {
                if (!socket.isOutputShutdown()) {
                    socket.shutdownOutput();
                    key.selected(OP_WRITE);
                }
            }
        } catch (SocketException e) {
            if (!socket.isConnected()) {
View Full Code Here

        try (Socket socket = new Socket("localhost", connector.getLocalPort());)
        {
            socket.setSoTimeout((int)connector.getIdleTimeout());

            Assert.assertTrue(openLatch.await(5, TimeUnit.SECONDS));
            socket.shutdownOutput();
            Assert.assertTrue(closeLatch.await(5, TimeUnit.SECONDS));
            String response=IO.toString(socket.getInputStream());
            Assert.assertEquals(0,response.length());

            // Wait some time to see if the callbacks are called too many times
View Full Code Here

                    "\r\n";
            byte[] h=header.getBytes(StandardCharsets.ISO_8859_1);
            out.write(h);
            out.write(content,0,4096);
            out.flush();
            socket.shutdownOutput();

            BufferedReader in = new BufferedReader(new InputStreamReader(socket.getInputStream()));
            assertThat(in.readLine(),containsString("HTTP/1.1 200 OK"));
            assertThat(in.readLine(),containsString("Content-Length:"));
            assertThat(in.readLine(),containsString("Server:"));
View Full Code Here

            assertTrue(System.currentTimeMillis() - start >= 400);
        }

        // write then shutdown
        client.getOutputStream().write("Goodbye Cruel TLS".getBytes(StandardCharsets.UTF_8));
        client.shutdownOutput();

        // Verify echo server to client
        for (char c : "Goodbye Cruel TLS".toCharArray())
        {
            int b = client.getInputStream().read();
View Full Code Here

        // and the server output is not shutdown
        assertFalse(server.isOutputShutdown());

        // until we explictly shut it down
        server.shutdownOutput();

        // and now we can't write
        try
        {
            server.getOutputStream().write(1);
View Full Code Here

        assertEquals(1, server.getInputStream().read());

        // Write from server to client with oshut
        server.getOutputStream().write(1);
        // System.err.println("OSHUT "+server);
        server.shutdownOutput();

        // Client reads response
        assertEquals(1, client.getInputStream().read());

        try
View Full Code Here

        assertEquals(1, server.getInputStream().read());

        // Write from server to client with oshut
        server.getOutputStream().write(1);
        //System.err.println("OSHUT "+server);
        server.shutdownOutput();

        try
        {
            // Client reads response
            assertEquals(1, client.getInputStream().read());
View Full Code Here

            // client endpoint reads EOF and shutdown input as result
            assertEquals(-1, client.getInputStream().read());
            client.shutdownInput();

            // client connection see's EOF and shutsdown output as no more requests to be sent.
            client.shutdownOutput();

            // Since input already shutdown, client also closes socket.
            client.close();

            // Server reads the EOF from client oshut and shut's down it's input
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.