Java Socket shutdownOutput() method25 Mar 2025 | 2 min read 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. SyntaxParameterNA ReturnNA ThrowsIOException - if an I/O error occurs while shutting down the given socket Example 1Output: The socket is connected: true The socket is bounded: true The socket is shutdown: true Example 2Output: Exception in thread "main" java.net.SocketException: Socket is not connected at java.net.Socket.shutdownOutput(Socket.java:1553) at com.tpointtech.JavaSocketShutdownOutputExample2.main(JavaSocketShutdownOutputExample2.java:10) Next TopicJava Socket Class |
Java method The getInetAddress() method of Java Socket class returns the address to which the socket is connected. If the socket is being closed, this method will return the connected address after the socket is closed. Syntax public InetAddress getInetAddress () Parameter NA Return The getInetAddress () method either returns the...
3 min read
Java method The getSoLinger () method of Java Socket class returns the setting if the SO_Linger option is set else it returns -1 if the option is disabled. This method only affects the setting for SO_LINGER. Syntax public int getSoLinger () Parameter NA Return The getSoLinger () method returns the setting for...
3 min read
Java method The setSoTimeout () method of Java Socket class enables or disables the SO_TIMEOUT option with the given timeout value, in milliseconds. The timeout value should be greater than 0 otherwise, it will throw an error. Syntax public void setSoTimeout (int timeout) throws SocketException Parameter The...
3 min read
Java method The isBound () method of Java Socket class returns a Boolean value representing the binding state of the socket. This method would continue to return 'true' for a closed socket, if it was bound before being closed. Syntax public boolean isBound() Parameter NA Return The isBound () method would...
3 min read
Java method The getReceiveBufferSize() method of Java Socket class returns the buffer size (SO_RCVBUF option) for this socket. Syntax public int getReceiveBufferSize () throws SocketException Parameter NA Returns The getReceiveBufferSize() method returns the buffer size or the SO_RCVBUF option for this socket. Throws SocketException - if there is an error in the underlying...
3 min read
Java method The getChannel() method of Java Socket class returns the unique SocketChannel object linked with this socket. Syntax public SocketChannel getChannel() Parameter NA Return The getChannel() method either returns the socket channel linked with this socket or returns null if the socket was not created for the specified channel. Example...
2 min read
Java method The setSoLinger() method of Java Socket class enables or disables the SO_LINGER option with the given linger time in seconds. It is used to specify how the close() method affects socket using a connection-oriented protocol. The timeout value is platform-specific, and this setting...
4 min read
Java method The getTrafficClass() method of Java Socket class returns the traffic class or type-of-service in the IP header sent from the specified Socket. Syntax public int getTrafficClass () Throws SocketException Parameter NA Return The getTrafficClass () method returns the traffic class or type-of-service. Throws SocketException - if there occurs an error while...
2 min read
Java method The getSendBufferSize () method of Java Socket class returns the buffer size(SO_SNDBUF) used by the platform for output on this socket. Syntax public int getSendBufferSize () Parameter NA Return The getSendBufferSize () method returns the value of the SO_SNDBUF option of the specified Socket. Throws SocketException - if an error...
2 min read
Java Socket setReuseAddress () method The setReuseAddress () method of Java Socket class enables or disables the SO_REUSEADDR socket option. The initial setting of SO_REUSEADDR is disabled. Syntax public void setReuseAddress (boolean on) throws SocketException Parameter The parameter 'on' states whether the SO_REUSEADDR option should be enabled or disabled. Return NA Throws SocketException -...
3 min read
We request you to subscribe our newsletter for upcoming updates.
We provides tutorials and interview questions of all technology like java tutorial, android, java frameworks
G-13, 2nd Floor, Sec-3, Noida, UP, 201301, India