Skip to content

Instantly share code, notes, and snippets.

@heapwolf heapwolf/35.js
Created Aug 7, 2012

Embed
What would you like to do?
tcp/client-connection
var net = require('net');
var port = 4001;
var host = 'localhost';
var conn = net.createConnection(port, host);
@heapwolf

This comment has been minimized.

Copy link
Owner 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
You can’t perform that action at this time.