Code example for SocketChannel

Methods: close, isOpen

0
 
	public void close() throws IOException, InterruptedException { 
		if (connected){
			connected = false;
			Thread.sleep(50);
			if (out_socket != null && out_socket.isOpen()){
				out_socket.close();
			} 
			if (in_socket != null && !in_socket.isClosed()){
				if (in != null){
					in.close();
				} 
				in_socket.close();
			} 
		} 
	} 
}