title: How do I implement a read / write client such as a POP3 client in node.js
body: <p>I'm not well versed in the art of node.js, so I'm not sure how to go about this: I want to write a client that can connect to a POP3 server and write to the server, and react to what ever the server sends back.</p>
  
  <ol>
  <li>Open connection to server</li>
  <li>Read server welcome</li>
  <li>Send "USER some_user@domain.com"</li>
  <li>Check for "+OK User Accepted"</li>
  <li>Send "PASS mypassword"</li>
  <li>Check for "+OK Pass Accepted"</li>
  </ol>
  
  <p>If the server replies with anything but OK, trigger an error event.</p>
  
  <p>What I have so far:</p>
  
  <pre><code>var   net = require('net')
      , sys = require('sys')
  ;
  
  conn = net.createConnection(110, 'mail.somehost.com');
  conn.setEncoding("utf8");
  //1. Open Connection
  conn.on('connect', function() {
      //2. Read welcome
      conn.once('data', function(data) {
          conn.pause();
          console.log('Server Welcome: ' + data);
          //4. Prepare to get response from server
          conn.once('data', function(data) {
              console.log('USER Response: ' + data);
          });
          //3. Send USER
          conn.write('USER some_user@domain.com' + "\n");
          conn.resume();
      })
  
  });
  </code></pre>
  
  <p>Will the conn.pause, handle return, conn.once, conn.write, conn.resume sequence work for all of the interaction?</p>