开发者

Bridging standard input/output over a TCP socket

I want to write a script that does the following:

  1. Start listening on a random available localhost TCP port.
  2. Start a certain external program passing the port number as an argument.
  3. Accept a single connection to the server socket.
  4. Send the script’s standard input into the socket, and the socket’s output to standard output.
  5. Exit when the external program exits.

The ideal solution would be a shell script invoking some reasonably standard tools, so if anybody can come up with a way to do that, well, that would be the perfect answer. If that proves intractable, a Ruby implementation wo开发者_运维知识库uld be convenient for me. Failing that, I’ll take any workable implementation.

P.S. I’m pretty new here, so please let me know if this question is too general or if it doesn’t belong for some other reason (maybe "please implement X for me" is frowned upon?).


Have you tried netcat ? Both listener and client can be done with nc.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜