Creating synchronous network i/o in Node land
<p>Are there any blocking <code>network</code> I/O libraries for Node.js? We have sync facilities for filesystem I/O, but I am not sure the equivalent exists for network I/O in Node.js.</p>

<p>We can create blocking network action like so:</p>

<pre><code>var available = true;
var messages = [];
var socket = io('http://localhost:8080');

socket.on('RESPONSE_RECEIVED', function () {
    available = true;  //we can confirm receipt, so we are free to process next message
    var msg = messages.shift();
    if (msg) {
        sendData(msg);
    }
});

function sendData(data) {
    if (available) {
        available = false;
        socket.emit('SEND_NEW_DATA', data);
    } else {
        messages.push(data);
    }
}
</code></pre>

<p>I have confirmed that this works pretty well..the socket connection waits for a response before processing the next message. If the socket is "busy" we just push on a new message on the queue. So it's a message queue.</p>

<p>Just wondering if there's anything lower level that we could use. I doubt it.</p>