Java Socket getTcpNoDelay() method25 Mar 2025 | 2 min read The getTcpNoDelay () method of Java Socket class returns the setting for SO_TIMEOUT option if it is enabled, else it returns false. SyntaxParameterNA ReturnThe getTcpNoDelay () method returns a Boolean value 'true' if the TCP_NODELAY is enabled. ThrowsSocketException - if an error is there in the underlying protocol, such as a TCP error. Example 1Output: SO_TIMEOUT option is enabled: true Example 2Output: SO_TIMEOUT option is enabled: false Example 3Output: Exception in thread "main" java.net.SocketException: Socket is closed at java.net.Socket.setTcpNoDelay(Socket.java:979) at com.tpointtech.JavaSocketGetTcpNoDelayExample3.main(JavaSocketGetTcpNoDelayExample3.java:14) Next TopicJava Socket Class |
Java method The getPort() method of Java Socket class returns the remote port number to which the socket is connected. This method will return the port number even after the socket is closed. Syntax public int getPort () Parameter NA Return The getPort() method either returns the port number to which...
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
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 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 get00BInline() method of Java Socket class tests whether the S0_00BINLINE option is enabled or not. Syntax public boolean get00BInline () Parameter NA Return The get00BInline() method returns a Boolean value 'true if the S0_00BINLINE is enabled else it returns false. Throws SocketException - if an error is there in...
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 getRemoteSocketAddress () method of Java Socket class returns the address of the endpoint of the specified socket if it is connected else it will return null if this socket is not connected. Syntax public SocketAddress getRemoteSocketAddress () Parameter NA Return The getRemoteSocketAddress () method either returns the SocketAddress...
3 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 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 isConnected () method of Java Socket class returns the connection state of the socket. This method would continue to return the connection state which was there before being closed. Syntax public boolean isConnected() Parameter NA Return The isConnected () method would return a Boolean value 'true' if the...
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