Java Socket shutdownOutput() method

The shutdownOutput() method of Java Socket class disables the output stream for the specified socket. If the socket output stream is written after invoking the shutdownOutput() method on the socket, the stream will throw an IOException.

Syntax

Parameter

NA

Return

NA

Throws

IOException - if an I/O error occurs while shutting down the given socket

Example 1

Test it Now

Output:

The socket is connected: true 
The socket is bounded: true
The socket is shutdown: true

Example 2

Test it Now

Output:

Exception in thread "main" java.net.SocketException: Socket is not connected
	at java.net.Socket.shutdownOutput(Socket.java:1553)
	at com.javaTpoint.JavaSocketShutdownOutputExample2.main(JavaSocketShutdownOutputExample2.java:10)




Latest Courses