News:

Choose a design and let our professionals help you build a successful website   - ITAcumens

Main Menu

Socket isClosed Example

Started by VelMurugan, Jan 07, 2009, 11:48 PM

Previous topic - Next topic

VelMurugan

Socket isClosed Example

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

Socket class isClosed example. public boolean isClosed() Returns the closed state of the socket.

Here is the code

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

import java.net.*;

public class IsClosed {

    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("Closed state of the socket " + socket.isClosed());

        socket.close();
       
        System.out.println("Closed state of the socket " + socket.isClosed());

    }
}


Output

Closed state of the socket false
Closed state of the socket true

Source : codingdiary