Skip to content

Instantly share code, notes, and snippets.

@heapwolf
Created August 7, 2012 05:45
Show Gist options
  • Save heapwolf/3282056 to your computer and use it in GitHub Desktop.
Save heapwolf/3282056 to your computer and use it in GitHub Desktop.
tcp/client-connection
var net = require('net');
var port = 4001;
var host = 'localhost';
var conn = net.createConnection(port, host);
@heapwolf
Copy link
Author

heapwolf commented Aug 7, 2012

function connectionListener(conn) {
  console.log('We have a new connection');
}

var conn = net.createConnection(port, host);
conn.once('connect', connectionListener);
function connectionListener(conn) {
  console.log('We have a new connection');
}

var conn = net.createConnection(port, host, connectionListener);

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment