Examples of shutdownOutput()


Examples of java.net.Socket.shutdownOutput()

        BufferedReader reader;
        try {
            writer = new BufferedWriter(new OutputStreamWriter(socket.getOutputStream(), "UTF-8"));
            writer.write(REQUEST);
            writer.flush();
            socket.shutdownOutput();
            reader = new BufferedReader(new InputStreamReader(socket.getInputStream(), "UTF-8"));
            String line;
            while ((line = reader.readLine()) != null) {
                System.out.println(line);
            }
View Full Code Here

Examples of java.net.Socket.shutdownOutput()

    public void disconnect() {
        try {
            this.connected = false;
            if ( socketChannel != null ) {
                Socket socket = socketChannel.socket();
                socket.shutdownOutput();
                socket.shutdownInput();
                socket.close();
                socketChannel.close();
                socket = null;
                socketChannel = null;
View Full Code Here

Examples of java.net.Socket.shutdownOutput()

    try {
      OutputStream outstream = sock.getOutputStream();
      outstream.write(cmd.getBytes());
      outstream.flush();
      // this replicates NC - close the output stream before reading
      sock.shutdownOutput();

      reader =
        new BufferedReader(
            new InputStreamReader(sock.getInputStream()));
      StringBuilder sb = new StringBuilder();
View Full Code Here

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

Examples of java.net.Socket.shutdownOutput()

            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

Examples of java.net.Socket.shutdownOutput()

        }
        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

Examples of java.net.Socket.shutdownOutput()

                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

Examples of java.net.Socket.shutdownOutput()

      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

Examples of java.net.Socket.shutdownOutput()

            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

Examples of java.net.Socket.shutdownOutput()

        } 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
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.