Socket shutdownOutput Example

Socket class shutdownOutput example. This example shows you how to use shutdownOutput method.


Socket class shutdownOutput example. public void shutdownOutput() throws IOException Disables the output stream for this socket. For a TCP socket, any previously written data will be sent followed by TCP's normal connection termination sequence.

Here is the code
/*
 * @ # ShutdownOutput.java
 * A class repersenting use to shutdownOutput method 
 * of Socket class in java.net package
 * version 17 June 2008
 * author Rose India 
 */

import java.net.*;
import java.io.*;

public class ShutdownOutput {

    public static void main(String args[]) throws Exception {
        byte buff[] new byte[64];
        InetAddress addr = InetAddress.getByName("192.168.10.222");
        Socket s = new Socket(addr, 8080);


        OutputStream output = s.getOutputStream();
        InputStream input = s.getInputStream();
        String GetCmd = "GET /index.html HTTP/1.0\r\n\r\n";
        GetCmd.getBytes(0, GetCmd.length(), buff, 0);
        output.write(buff);
        input.read(buff, 0, buff.length);
        System.out.println(new String(buff, 0));
        s.shutdownInput();
        s.shutdownOutput();
    }
}

Output
run-single:
HTTP/1.1 200 OK
Server: Apache-Coyote/1.1
ETag: W/"7347-118489

Post Comment
Name:
E-mail:
Contact no :
Comments:
  Refresh Image
Verify Image:
 
 
Your Comment's
 
 
 

HOME | COPYRIGHT | CONTACT US