标签:system 路由 soc 远程 host 后台 boolean string nts
在最近项目中,由于netty服务地址从路由中心远程调用,在netty服务挂了之后,路由中心不能够实时监控到,仍然保留netty地址,这时需要使用netty服务时候
需要知道netty服务地址是真的可用,这里用socket方式来检测netty服务的远程端口是否可用
public static boolean checknettyService(String host, int port) {
Socket socket = new Socket(); try { socket.connect(new InetSocketAddress(host, port)); } catch (IOException e) { system.out.print("netty服务不可以"); return false; } finally { try { socket.close(); } catch (IOException e) { e.printStackTrace(); } } return true; }标签:system 路由 soc 远程 host 后台 boolean string nts
原文地址:https://www.cnblogs.com/ketoli/p/14767414.html