title: Inter-process communication between node and C application
body: <p>I have 2 software componnects I'd like to make talk to each other,</p>
  
  <ol>
  <li>A node.js web application</li>
  <li>A dedicated server written in C (a fairly simple piece of code that deals with some obscure library that i'd rather not wrap for other languages)</li>
  </ol>
  
  <p>The conversations I'd like to have are pretty simple,</p>
  
  <ul>
  <li>Node: Setup resource id A</li>
  <li>C app: Ok, here's the ref num</li>
  </ul>
  
  <p>or</p>
  
  <ul>
  <li>Node: Take down this ref</li>
  <li>C app: Sure, mate.</li>
  </ul>
  
  <p>Is there any painless way to pass messages between the 2?</p>
  
  <p>My theoretical idea currently is something along these lines:</p>
  
  <ol>
  <li>Have 1 tcp/unix socket between the 2 processes, 1 session only to avoid opening and closing sessions all the time (also afraid there'd be too much at once).</li>
  <li>Each matching node request and C app response bear same ID (tcp-esque sessions over single tcp session)</li>
  <li>Each relevant node request would generate message to C app, have the response objects stored in some hash with session ids as keys.</li>
  <li>Have a single node thread to collect C app replies, find response objects by session id and respond to client</li>
  </ol>
  
  <p>Is it terribly inefficient?</p>
  
  <p>Is there actually thread support in node? (a short google didn't bring up any concrete results)</p>