Socket getSoLinger Example

Started by VelMurugan, Jan 10, 2009, 01:04 PM

Previous topic - Next topic

VelMurugan

Socket getSoLinger Example

Socket class getSoLinger example. This example shows you how to use getSoLinger method.

Socket class getSoLinger example. public int getSoLinger() throws SocketException Returns setting for SO_LINGER. -1 returns implies that the option is disabled. The setting only affects socket close.

Here is the code

/*
* @ # GetSoLinger.java
* A class repersenting use to getSoLinger method
* of NumberFormat class in java.text package
* version 17 June 2008
* author Rose India
*/

import java.net.*;

public class GetSoLinger {

    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.211", 8080));

        System.out.println("SoLinger " + socket.getSoLinger());

        //close socket
        socket.close();
    }
}


Output

SoLinger -1

Source : codingdiary

nandagopal



This code work great !!!

Nice code