Currently I have a write a networking app writen in C. It is boring to handle networking, protocol parse, json parse, I want to use Ruby to handle these tasks, which is every easy in Ruby.

I currently write a MRI Ruby app as a separate daemon, talk with my C app with uninx socket message. But it is not neat like function call in a single one app.

I found mruby is every lightweight, so I want to embed mruby into C app, make mruby code as a running service, talk with C function directly.

I serarch mruby document, and found some code example, such as http://mruby.org/docs/articles/executing-ruby-code-with-mruby.html and this https://github.com/mruby/mruby/wiki/Building-your-Ruby-environment-and-accessing-it. But it is too easy, just create mruby vm, load ruby code, execute it, then close mruby vm.

Could you give me some tip on how to design a useful mruby service work together c? Maybe I should create a pthrad for mruby code?

0 Answers