分类: LINUX
2011-03-26 22:13:57
来源:unp实验1-多进程记录
关键: nestat 参数 –pna ,如果只是-a 好像不行。
小结0:配合grep的重定向,请给出尽量多的参数
小结:先开服务器,再开客户端,其中发起端c01,能检索到。呵呵。这是三次握手的原理
代码解释:
os66@liuliu-os66:~/Downloads/fscap$ netstat -pna|grep C01
(Not all processes could be identified, non-owned process info
will not be shown, you would have to be root to see it all.)
tcp 0 0 127.0.0.1:39877 127.0.0.1:9877 ESTABLISHED 15335/C01
os66@liuliu-os66:~/Downloads/fscap$ netstat -pna|grep S01
(Not all processes could be identified, non-owned process info
will not be shown, you would have to be root to see it all.)
附其他参数测试:
小结:netstat给出的参数越多越有利有grep的速度。当然这是筛选的结果。 没有使用参数,或者使用-p,或者-a都会等待很长时间
os66@liuliu-os66:~/Downloads/fscap$ netstat |grep C01
^C
os66@liuliu-os66:~/Downloads/fscap$ netstat -p|grep C01
(Not all processes could be identified, non-owned process info
will not be shown, you would have to be root to see it all.)
^C
os66@liuliu-os66:~/Downloads/fscap$ netstat -pn|grep C01
(Not all processes could be identified, non-owned process info
will not be shown, you would have to be root to see it all.)
tcp 0 0 127.0.0.1:39877 127.0.0.1:9877 ESTABLISHED 15335/C01
os66@liuliu-os66:~/Downloads/fscap$