From: Michael Neumann Date: 2001-12-31T00:28:52+09:00 Subject: [ruby-talk:29727] Re: Communicating with C/C++ program Hubert Hung-Hsien Chang wrote: > If I am using Microsoft Window OS(95+) and want to communicate with > Ruby program, what is the 'easiest' way to do it? Certainly I could > write a local host socket and ask them to talk to each other > but that is laborious ( for the C/C++ part). Previously ( some months ago?) > I ask about calling Ruby from C and Phil said 'system()'. (Thanks Phil!) > > What if I want not only to issue a command from C and ask Ruby to do something > but also getting the result from Ruby? Is socket the only way to do it? You could embed the Ruby interpreter into your C/C++ application, if this is possible for you. Then you can use the full Ruby C-API to call Ruby methods etc. Or if you start the Ruby application from you C-application or vice versa you could use pipes instead of sockets, which is probably a little bit easier to handle than sockets (but you may get problems with two-way pipes, which is as far as I know not possible on Windows). You could also use SOAP or XML-RPC, both available for C/C++ and Ruby. Then, either run a XML-RPC or SOAP service in C or Ruby, or simply communicate using files containing XML-RPC or SOAP messages, instead of running a TCP/IP server. For me, this seams to be the easiest way to communicate between C and Ruby. There is even a COM implementation (of course a C/C++ implementation exist, too) for XML-RPC and I guess for SOAP, too. So it shouldn't be a problem to use it from within your C/C++ program. Happy New Year! Regards, Michael -- Michael Neumann merlin.zwo InfoDesign GmbH http://www.merlin-zwo.de