title: NodeJS: How can I create a fake tcp socket for testing servers
body: <p>I'm trying to unit test my server code (non-http, custom protocol). I need to create a mock duplex socket that I can send messages to asynchronously and receive messages from.</p>
  
  <p>I've had some marginal success creating a duplex stream from event-stream readArray and writeArray, but readArray requires having the data up front, and writeArray doesn't fire until the stream ends. I need to test over time.  An ideal solution would be two duplex sockets linked together.</p>
  
  <p>Are there any existing solutions for this? I'd rather not have to resort to initializing an actual server to test this.</p>