Socket getFormats Example
Socket class getFormats example. This example shows you how to use getFormats method.
Socket class getFormats example. public boolean getKeepAlive() throws SocketException Tests if SO_KEEPALIVE is enabled.
Here is the code
/*
* @ # GetKeepAlive.java
* A class repersenting use to getKeepAlive method
* of NumberFormat class in java.text package
* version 17 June 2008
* author Rose India
*/
import java.net.*;
public class GetKeepAlive {
public static void main(String args[]) throws Exception {
Socket socket = new Socket();
//Connects this socket to the server.
socket.connect(new InetSocketAddress("192.168.10.80", 9090));
System.out.println("Tests SO_KEEPALIVE is enabled. " + socket.getKeepAlive());
socket.setKeepAlive(true);
System.out.println("Tests SO_KEEPALIVE is enabled. " + socket.getKeepAlive());
//close socket
socket.close();
}
}
|
Output
Tests SO_KEEPALIVE is enabled. false
Tests SO_KEEPALIVE is enabled. true |
|