Java Socket setTcpNoDelay() methodLast Updated : 17 Mar 2025 The setTcpNoDelay () method of Java Socket class enables or disables the TCP_NODELAY option. SyntaxParameterThe parameter 'on' represents enables or disables the TCP_NODELAY option. ReturnNA 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 disabled Example 3Output: Exception in thread "main" java.net.SocketException: Socket is closed at java.net.Socket.setTcpNoDelay(Socket.java:979) at com.tpointtech.JavaSocketSetTcpNoDelayExample3.main(JavaSocketSetTcpNoDelayExample3.java:15) Next TopicJava Socket Class |
We request you to subscribe our newsletter for upcoming updates.

We deliver comprehensive tutorials, interview question-answers, MCQs, study materials on leading programming languages and web technologies like Data Science, MEAN/MERN full stack development, Python, Java, C++, C, HTML, React, Angular, PHP and much more to support your learning and career growth.
G-13, 2nd Floor, Sec-3, Noida, UP, 201301, India