Java Socket isInputShutdown() method25 Mar 2025 | 2 min read The isInputShutdown () method of Java Socket class returns a Boolean value 'true' if the read-half of the socket connection has been closed, else it returns false. SyntaxParameterNA ReturnThe isInputShutdown () method returns a Boolean value 'true' if the socket has been shut down successfully. Example 1Output: The socket is connected: true The socket is bounded: true Input is shutdown: false Example 2Output: Input is shutdown: true Example 3Output: Exception in thread "main" java.net.SocketException: Socket is not connected at java.net.Socket.shutdownInput(Socket.java:1523) at com.tpointtech.JavaSocketShutdownInputExample3.main(JavaSocketShutdownInputExample3.java:11) Next TopicJava Socket Class |
Java method The shutdownInput() method of Java Socket class places the input stream for the specified socket at the end of the stream. When this method is invoked on the socket, the stream's available method returns 0, and its read methods return -1 (end of...
4 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 method The getInputStream() method of Java Socket class returns an input stream for the given socket. If you close the returned InputStream, then it will close the linked socket. Syntax public InputStream getInputStream () throws IOException Parameter NA Return The getInputStream() returns an input stream for reading bytes...
3 min read
Java method The bind() method of Java Socket class binds the socket to a local address. If the specified address is null, then the system will automatically pick up a port number and a valid local address to bind with the socket. Syntax public void bind(SocketAddress bindpoint)...
3 min read
Java method The getOutputStream() method of Java Socket class returns an output stream for the given socket. If you close the returned OutputStream then it will close the linked socket. Syntax public OutputStream getOutputStream() throws IOException Parameter NA Return The getOutputStream() returns an output stream for writing bytes to this socket. Throws IOException-...
3 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 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 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 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 method The getKeepAlive() method of Java Socket class tests whether SO_KEEPALIVE option is enabled or not. Syntax public boolean getKeepAlive () Parameter NA Return The getKeepAlive() method either returns a Boolean indicating whether SO_KEEPALIVE option is enabled or not. Throws SocketException - if there is an error in the underlying protocol, such...
2 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