Example usage for java.net Socket getKeepAlive

List of usage examples for java.net Socket getKeepAlive

Introduction

In this page you can find the example usage for java.net Socket getKeepAlive.

Prototype

public boolean getKeepAlive() throws SocketException 

Source Link

Document

Tests if SocketOptions#SO_KEEPALIVE SO_KEEPALIVE is enabled.

Usage

From source file:Main.java

public static void main(String[] args) throws Exception {
    Socket client = new Socket("google.com", 80);

    System.out.println(client.getKeepAlive());

    client.close();/*  w w w. j a va 2s. com*/
}

From source file:Main.java

public static void main(String[] args) throws Exception {
    Socket client = new Socket("google.com", 80);
    client.setKeepAlive(true);/*from  w  w  w. ja v a  2  s  .c  o  m*/
    System.out.println(client.getKeepAlive());

    client.close();
}