Java examples for java.nio.channels:SocketChannel
is Socket Connected
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*/ }