is Socket Connected - Java java.nio.channels

Java examples for java.nio.channels:SocketChannel

Description

is Socket Connected

Demo Code


import java.net.Socket;
import java.nio.channels.SelectionKey;
import java.nio.channels.ServerSocketChannel;
import java.nio.channels.SocketChannel;
import org.apache.log4j.Logger;

public class Main{
    public static boolean isConnected(Socket socket) {
        return socket != null && socket.isBound() && !socket.isClosed()
                && socket.isConnected() && !socket.isInputShutdown()
                && !socket.isOutputShutdown();
    }/*from  w  w w . ja va2 s  .c om*/
}

Related Tutorials