Got socket.on working
This commit is contained in:
parent
99dcd841ed
commit
ea45d63909
17
index.js
17
index.js
@ -1,19 +1,30 @@
|
|||||||
var net = require('net');
|
var net = require('net');
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Log the request and forward it.
|
||||||
|
* @param {String} bytes
|
||||||
|
*/
|
||||||
async function logAndSend(bytes) {
|
async function logAndSend(bytes) {
|
||||||
|
console.log(bytes)
|
||||||
}
|
}
|
||||||
|
|
||||||
var server = net.createServer((socket) => {
|
var server = net.createServer((socket) => {
|
||||||
socket.on('end', (c) => {
|
socket.on('end', (c) => {
|
||||||
console.log("Client disconnected");
|
console.log("Client disconnected");
|
||||||
});
|
});
|
||||||
|
socket.on("data", (c) => {
|
||||||
|
logAndSend(c.toString());
|
||||||
|
});
|
||||||
})
|
})
|
||||||
|
|
||||||
server.on('connection', () => {
|
server.on('connection', (c) => {
|
||||||
console.log("Client connected!");
|
console.log("Client connected!" + c.read(10));
|
||||||
});
|
});
|
||||||
|
|
||||||
|
server.on("listening", (c) => {
|
||||||
|
console.log("LISTENING");
|
||||||
|
})
|
||||||
|
|
||||||
server.listen(8124, () => {
|
server.listen(8124, () => {
|
||||||
console.log("Server bound.");
|
console.log("Server bound.");
|
||||||
})
|
})
|
Loading…
Reference in New Issue
Block a user