Interprocess communication in Lua with Example?

霸气de小男生 提交于 2021-01-21 10:26:32

问题


I have been struggling a lot to get this to work. Can someone provide an example with any LUA api of 2 scripts that pass a message back and forth.

I have tried Oil, lua-ipc and zeromq. But I face several missing libraries issues.

The ultimate goal is to pass a vector of numbers from one Lua process to another Lua process (with a different version of Lua) without going through disk.

Here is a similar example in python of IPC in a single file. Something similar in lua would be extremely helpful.

I really need an example as my knowledge in pipes or UDP/TCP is not strong.


回答1:


The equivalent would be to use luasocket. These examples come very close to the python example given. Here socket:receive() is used for the framing.

https://github.com/diegonehab/luasocket/blob/master/samples/listener.lua

https://github.com/diegonehab/luasocket/blob/master/samples/talker.lua



来源:https://stackoverflow.com/questions/40893558/interprocess-communication-in-lua-with-example

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!