代码改变世界

客户端及服务端_终端模拟

2020-04-08 16:19  改改~_~  阅读(234)  评论(0编辑  收藏  举报

环境:

1.安装homebrew
https://www.cnblogs.com/jpr-ok/p/12652245.html
2.通过brew安装nmap
https://www.cnblogs.com/jpr-ok/p/12652297.html

服务端:

(base) localhost:~ ligaijiang$ ncat -l 9999
Hello I am William's server~  #输入1
Hello I am William's client~   #输出2
bye~   #输入3

按control+c退出,同时客户端也会退出

 

客户端:

(base) localhost:~ ligaijiang$ ncat localhost 9999
Ncat: Could not resolve hostname "localhost": nodename nor servname provided, or not known. QUITTING.
(base) localhost:~ ligaijiang$ ping localhost
ping: cannot resolve localhost: Unknown host
(base) localhost:~ ligaijiang$ ncat 172.31.50.245 9999
Hello I am William's server~   #输出1
Hello I am William's client~    #输入2
bye~ #输出3