From ea45d63909a05332dfedf5c5ae03cc3e6c011aba Mon Sep 17 00:00:00 2001 From: jaketothepast Date: Thu, 24 Jan 2019 20:43:49 -0500 Subject: [PATCH] Got socket.on working --- index.js | 17 ++++++++++++++--- 1 file changed, 14 insertions(+), 3 deletions(-) diff --git a/index.js b/index.js index 1add1fe..642c9e9 100644 --- a/index.js +++ b/index.js @@ -1,19 +1,30 @@ var net = require('net'); +/** + * Log the request and forward it. + * @param {String} bytes + */ async function logAndSend(bytes) { - + console.log(bytes) } var server = net.createServer((socket) => { socket.on('end', (c) => { console.log("Client disconnected"); }); + socket.on("data", (c) => { + logAndSend(c.toString()); + }); }) -server.on('connection', () => { - console.log("Client connected!"); +server.on('connection', (c) => { + console.log("Client connected!" + c.read(10)); }); +server.on("listening", (c) => { + console.log("LISTENING"); +}) + server.listen(8124, () => { console.log("Server bound."); }) \ No newline at end of file