Java Socket isOutputShutdown() method25 Mar 2025 | 2 min read The isOutputShutdown () method of Java Socket class returns a Boolean value 'true' if the write-half of the socket connection has been closed successfully, else it returns false. SyntaxParameterNA ReturnThe isOutputShutdown () method would return a Boolean value 'true' if the output of the socket has been shut down. Example 1Output: The socket is connected: true The socket is bounded: true Output is shutdown: true Example 2Output: The socket is connected: true The socket is bounded: true Output is shutdown: false Example 3Output: Exception in thread "main" java.net.SocketException: Socket is not connected at java.net.Socket.shutdownOutput(Socket.java:1553) at com.tpointtech.JavaSocketIsOutputShutdownExample3.main(JavaSocketIsOutputShutdownExample3.java:10) Next TopicJava Socket Class |
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 getLocalPort() method of Java Socket class returns the local port number to which the specified socket is bound. If the socket was being closed, this method will return the connected port number after the socket is closed. Syntax public int getLocalPort() Parameter NA Return The getLocalPort () method...
2 min read
Java Socket getReuseAddress () method The getReuseAddress () method of Java Socket class tests whether the SO_REUSEADDR option is enabled or not. It throws SocketException if finds an error in the underlying protocol, such as a TCP error. Syntax public boolean getReuseAddress() Parameter NA Return The getReuseAddress () method returns a...
2 min read
Java method The setReceiveBufferSize() method of Java Socket class sets the SO_RCVBUF option to the given value for the specified socket. The buffer size should be greater than zero else, it will throw an IllegalArgumentException. Syntax public void setReceiveBufferSize (int size) throws SocketException Parameter The parameter 'size' represents the...
2 min read
Java method The getLocalSocketAddress() method of Java Socket class returns the address of the endpoint to which this socket is bound. This method will continue to return an InetSocketAddress even after the socket is closed. Syntax public SocketAddress getLocalSocketAddress () Parameter NA Return The getLocalSocketAddress() method returns: the SocketAddress, representing the...
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 close() method of Java Socket class closes the specified socket. Once the socket has been closed, it is not available for further networking use. If the socket has a channel, the channel is also closed. Syntax public void close () throws IOException Parameter NA Return NA Specified by The close()...
2 min read
Java The Socket class acts as an endpoint for communication between two machines. It implements client sockets. Methods Method Description bind(SocketAddress bindpoint) This method binds the given socket to the specified local address. close() This method closes the socket. connect(SocketAddress endpoint) connect(SocketAddress endpoint, int timeout) The connect() method connects this socket to the server. This method...
8 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 sendUrgentData() method of Java Socket class sends one byte of urgent data on the socket. The byte should be the lowest eight bits of the data parameter. Syntax public void sendUrgentData (int data) throws IOException Parameter The "data" parameter represents the byte of data to send. Return NA Throws IOException...
4 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