BSD nc(netcat)不会在EOF上终止

主持人A:

tar cf - stuff | dd | nc -N -l 12987 

主持人B:

 nc a.example.com 12987 | dd | tar tf - 

在主机上ddtar完成后打印它的总结。 因此很明显,tarclosures了pipe道/文件 – > EOF

165040 + 0logging在165040 + 0logging出84500480字节在25.464802秒(3318325字节/秒)

在这两个主机上, nc高兴地坐在那里,不退出。 nc(1)

  -N shutdown(2) the network socket after EOF on the input. Some servers require this to finish their work. 

因此,在主机上nc应该已经看到了EOF ,closures了该死的socket并且主机B nc应该已经看到了TCP连接终止,并且应该已经closures了stdoutstdin of dd / tar )。

如何告诉ncclosures主机B的stdout /终止并终止在主机A上

nc错误?

-D (debugging)什么都不做。 nc甚至不能告诉它的版本号… 叹气

两台主机都是FreeBSD 10.3-RELEASE-p4 ,仅限IPv4。

ncbuild立一个双向连接。 即它从主机B发送stdin到主机A以及所需的从A到B.

在主机B上使用-d忽略stdin-N在主机A上仍然需要closuresEOF上的TCP连接。


综上所述

主持人A:

 tar cf - stuff | dd | nc -N -l 12987 

主持人B:

 nc -d a.example.com 12987 | dd | tar tf -