Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Nodejs communicate with C++ program?

Say I've got a c++ program running on the same server with a Node.js web app, on a linux server.

The c++ program maintains a queue, and what I want to do with Node.js is, push some data into the queue.

What's the best way to do this?

Which is better? sockets or IPC?

like image 646
NamiW Avatar asked Mar 23 '12 16:03

NamiW


2 Answers

If you're using Linux, I would suggest UNIX-domain sockets. They basically give you the high-performance of IPC using the BSD socket interface, making it easy to switch for TCP sockets later if you need to move the C++ (or node.js) application to a different computer.

They're already supported by node.js and only the code that opens the socket will need to be changed. Many applications, including MySQL easily abstract this away in a configuration file.

like image 69
André Caron Avatar answered Oct 14 '22 02:10

André Caron


I'd use sockets, they are clean and easy to use

like image 21
luke14free Avatar answered Oct 14 '22 03:10

luke14free