file transfer with nc command on Linux

1、先在receiver上使用nc监听端口(6543),并将接收的内容都重定向到文件里(out.file)

nc -lvp 6543 > out.file

2、在sender上将文件发送至receiver机器的端口上

nc -q 1 ip 6543 < in.file

为了能够自动退出,增加里-q选项

-q seconds   after EOF on stdin, wait the specified number of seconds
             and then quit. If seconds is negative, wait forever.