drcomwc134525 2014-03-10 07:27
浏览 55
已采纳

如何:与子流程进行通信

I have a Go program that starts a C/Lua process. Now I'd like to communicate between those two. For example, in the middle of the run of the child (the c/lua process), I'd like to ask the parent (the Go program) to do some calculations and wait for the result. I am not keen to use stdin/stdout for communication, as this is already used for regular output. Now I am thinking of using sockets for the communication, but I don't want to reinvent the wheel.

  • What are the obvious choices for this kind of communication?
  • Is there a (more or less) simple standard way to pass objects between Lua and Go? If not, text blobs would suffice.
  • Are Protocol Buffers suitable for this? Looks like overkill, but I have no experience here.
  • 写回答

2条回答 默认 最新

  • dousou2911 2014-08-15 14:22
    关注

    I now talk to the subprocess via regular tcp sockets. The child process (Lua) has luasocket built in and this seems to work on Windows, Mac and Linux without problems.

    Also, I have (for now) defined my own very simple protocol which looks OK in the first steps.

    Just in case anybody is interested: https://github.com/speedata/publisher/commit/ea253382c1096274bca2d4124867c39cd0d512e5 and the child commits implement the tcp connection.

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(1条)

报告相同问题?