Java Socket getKeepAlive() methodThe getKeepAlive() method of Java Socket class tests whether SO_KEEPALIVE option is enabled or not. SyntaxParameterNA ReturnThe getKeepAlive() method either returns a Boolean indicating whether SO_KEEPALIVE option is enabled or not. ThrowsSocketException - if there is an error in the underlying protocol, such as a TCP error. Example 1Test it NowOutput: SO_KEEPALIVE is enabled: true Example 2Test it NowOutput: SO_KEEPALIVE is enabled: false Example 3Test it NowOutput: Exception in thread "main" java.net.SocketException: Socket is closed at java.net.Socket.getKeepAlive(Socket.java:1325) at com.javaTpoint.JavaSocketGetKeepAliveExample3.main(JavaSocketGetKeepAliveExample3.java:11) Next TopicJava Socket Class |
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