Skip to content

Instantly share code, notes, and snippets.

@hyounggyu
Last active December 15, 2015 15:19
Show Gist options
  • Select an option

  • Save hyounggyu/5281462 to your computer and use it in GitHub Desktop.

Select an option

Save hyounggyu/5281462 to your computer and use it in GitHub Desktop.
/* https://gist.github.com/creationix/707146 */
var net = require('net');
var server = net.createServer(function (socket) {
socket.on('data', function (data) {
var message;
try {
message = JSON.parse(data);
} catch (e) {
console.log('Could not parse JSON: '+e.message+'\nRequest data: '+data);
}
if (message !== undefined && message.command !== undefined) {
switch (message.command) {
case "hello":
console.log(message.data);
break;
}
}
});
});
server.listen(3303, '127.0.0.1');
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment