client.js
// construct a packet and then send it
construct a packet and then send it
construct a packet and then send it
function sendMessage(txt) {
	if(txt==='exit'){
		client.close();
		process.exit();
	}
	var message = new Buffer("SEND" + lpad(count++) + lpad(id) + lpad(friendId) + txt);
	client.send(message, 0, message.length, PORT, HOST, function(err, bytes) {
		if (err) throw err;
	});
	return true;
}
function sendMessage ( txt ) { if ( txt === 'exit' ) { client . close ( ) ; process . exit ( ) ; } var message = new Buffer ( "SEND" + lpad ( count ++ ) + lpad ( id ) + lpad ( friendId ) + txt ) ; client . send ( message , 0 , message . length , PORT , HOST , function ( err , bytes ) { if ( err ) throw err ; } ) ; return true ; }
construct a packet and then send it
construct a packet and then send it
// Exit when user types exit // construct the message // send message