This week only. Pastebin PRO Accounts Christmas Special! Don't miss out!Want more features on Pastebin? Sign Up, it's FREE!
Guest

Untitled

By: a guest on Mar 8th, 2013  |  syntax: JavaScript  |  size: 0.53 KB  |  views: 48  |  expires: Never
download  |  raw  |  embed  |  report abuse  |  print
Text below is selected. Please press Ctrl+C to copy to your clipboard. (⌘+C on Mac)
  1. var net = require("net");
  2. srv = net.createServer();
  3. srv.listen(8888);
  4.  
  5. srv.on('error', function(e) { console.log("Server got an error: " + e.message);});
  6. srv.on('connection', function(socket){console.log("connected "+ socket.readable);
  7.         socket.write("It's the right socket");
  8. socket.on('error', function(e) { console.log("Socket got an error: " + e.message);});
  9.  
  10.         socket.on("data", function(chunk){
  11.                 console.log("SOCKET: " +chunk);
  12.  
  13.         });
  14.  
  15.  
  16. });
  17.  
  18. console.log("Server has started.");
  19. ~
clone this paste RAW Paste Data