How to make an Echo server with Bash?

后端 未结 5 1464
伪装坚强ぢ
伪装坚强ぢ 2020-12-12 20:58

How to write a echo server bash script using tools like nc, echo, xargs, etc capable of simultaneously processing requests from multiple clients each with durable connection

5条回答
  •  陌清茗
    陌清茗 (楼主)
    2020-12-12 21:28

    If you use ncat instead of nc your command line works fine with multiple connections but (as you pointed out) without -p.

    ncat -l 2000 -k -c 'xargs -n1 echo'
    

    ncat is available at http://nmap.org/ncat/.

    P.S. with the original the Hobbit's netcat (nc) the -c flag is not supported.

    Update: -k (--keep-open) is now required to handle multiple connections.

提交回复
热议问题