赞
踩
某次服务端软件升级后,客户端软件刚开始能访问,以后就不能访问了,最终的结果是获取不到服务端的数据。然后开始定位问题,最终定位到时host的问题,当时终端用户并不知道服务端端口已发生变化,所以此时要探测代码里面的写的端口是否能用,当服务端人员不能立即给出回复时,终端人员还自己进行端口探测,找到合适端口进行请求。
之前写过用select+connect函数探测端口,但是用起来比较复杂,linux下nc命令可以很好的解决这个问题。
[mapan@localhost unixNetwork]$ nc -nvz 127.0.0.1 8880-8888
nc: connect to 127.0.0.1 port 8880 (tcp) failed: Connection refused
nc: connect to 127.0.0.1 port 8881 (tcp) failed: Connection refused
nc: connect to 127.0.0.1 port 8882 (tcp) failed: Connection refused
nc: connect to 127.0.0.1 port 8883 (tcp) failed: Connection refused
nc: connect to 127.0.0.1 port 8884 (tcp) failed: Connection refused
nc: connect to 127.0.0.1 port 8885 (tcp) failed: Connection refused
nc: connect to 127.0.0.1 port 8886 (tcp) failed: Connection refused
nc: connect to 127.0.0.1 port 8887 (tcp) failed: Connection refused
nc: connect to 127.0.0.1 port 8888 (tcp) failed: Connection refused
我们没有开启服务端,所以这里没有探测到。用telnet命令也可以,但是telent不能批量。
参考地址:http://blog.csdn.net/stpeace/article/details/79244090
Copyright © 2003-2013 www.wpsshop.cn 版权所有,并保留所有权利。