Package java.net

Examples of java.net.Socket.shutdownOutput()


      public String call() throws Exception {
        Socket client = listenSocket.accept();
        client.setSoTimeout(2000);
        try {
          client.getOutputStream().write(response.getBytes());
          client.shutdownOutput();
          byte[] buf = new byte[4*1024]; // much bigger than request
          int n = client.getInputStream().read(buf);
          return new String(buf, 0, n);
        } finally {
          client.close();
View Full Code Here


            throws IOException {
            ServerSocket serverSocket = new ServerSocket();
            serverSocket.bind(new InetSocketAddress(port));
            Socket socket = serverSocket.accept();
            InputStream is = socket.getInputStream();
            socket.shutdownOutput();
            final byte[] buf = new byte[2 * 4096];
            while (true) {
                int count = is.read(buf);
                if (count == -1) {
                    System.out.println("Remote stream closed");
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

                if (_channel instanceof SocketChannel)
                {
                    // TODO - is this really required?
                    Socket socket= ((SocketChannel)_channel).socket();
                    if (!socket.isClosed() && !socket.isOutputShutdown())
                        socket.shutdownOutput();
                }
            }
            catch(IOException e)
            {
                Log.ignore(e);
View Full Code Here

      public void run() {
        while (true) { // fetching does a few retries
          try {
            Socket s = socket.accept();
            s.getOutputStream().write(1234);
            s.shutdownOutput();
          } catch (Exception e) {
            break;
          }
        }
      }
View Full Code Here

            PrintWriter out = new PrintWriter(
                    socket.getOutputStream());
//            System.out.println("Message: " + requestMessage);
            out.println(requestMessage);
            out.flush();
            socket.shutdownOutput();
            return socket.getInputStream();
        } catch (MalformedURLException e) {
            log.info(e.getMessage());
        } catch (IOException e) {
            log.info(e.getMessage());
View Full Code Here

        } finally {
            try {
                // close socket if it's open
                if ((socket != null) && !socket.isClosed()) {
                    socket.shutdownOutput();
                    socket.shutdownInput();
                    socket.close();
                    logger.info("Socket was closed!");
                }
                stopServer();
View Full Code Here

        Socket sock = this.socket;
        try {
            doFlush();
            try {
                try {
                    sock.shutdownOutput();
                } catch (IOException ignore) {
                }
                try {
                    sock.shutdownInput();
                } catch (IOException ignore) {
View Full Code Here

        Socket sock = this.socket;
        try {
            doFlush();
            try {
                try {
                    sock.shutdownOutput();
                } catch (IOException ignore) {
                }
                try {
                    sock.shutdownInput();
                } catch (IOException ignore) {
View Full Code Here

        // Regression test for HARMONY-873
        ServerSocket ss2 = new ServerSocket(0);
        Socket s = new Socket("127.0.0.1", ss2.getLocalPort());
        ss2.accept();
        s.shutdownOutput();
        try {
            s.getOutputStream();
            fail("should throw SocketException");
        } catch (SocketException 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.