سؤال

I can easily launch two or more separate Lua programs (running on LuaJIT2) on the same machine. But is there any way how these programs can communicate?

The best solution I can come up with is that each program can write a text file that orher program can read. But this is ree-aalllyyy slow solution (even if text files are saved on virtual RAM disks).

I know that thera are zeromq and other things that may help with this... The problem is that instructions are just too long and complicated / confusing (for me at least).

Any recommendations? Especially some working code example would be appreciated, no matter how simple. Even how to pass value of one variable from one LuaJIT2 process to another.

(I'm using Windows XP SP3, if that matters...)

هل كانت مفيدة؟

المحلول

Essentially, they keyword you should be looking for is "IPC" (Inter-Process Communication).

Some of the options you might want to explore:

  • Shared files
  • Shared memory
  • Network Sockets
  • Pipes (on POSIX systems)
  • Middleware utilizing one of the above

I can't really say that one of them is the best. The choice would depend on the other factors (needed speed, latency, what do you want to communicate), that you didn't provide. I just hope I pointed you in the right direction.

Also, if ZeroMQ is too complicated, i highly recommend you more reading, rather than looking for even simpler code examples. Lua is "do-it-yourself" language.

If you aren't really stick to Lua, take a look at PyRo (Python Remote Objects). Or you might want to implement something like this yourself.

مرخصة بموجب: CC-BY-SA مع الإسناد
لا تنتمي إلى StackOverflow
scroll top