Skip to content

Instantly share code, notes, and snippets.

@whamtet
Created July 12, 2022 04:53
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save whamtet/78967a9eef48124af3280cb64da3b2fa to your computer and use it in GitHub Desktop.
Save whamtet/78967a9eef48124af3280cb64da3b2fa to your computer and use it in GitHub Desktop.
var net = require('net');
const evalToBuffer = d => {
try {
const result = eval(d.toString());
return Buffer.from(result + '\n', "utf-8");
} catch (e) {
return Buffer.from(e + '\n', "utf-8");
}
};
var server = net.createServer(function(socket) {
socket.write('Go go go!\r\n');
socket.on('data', d => socket.write(evalToBuffer(d)));
});
server.listen(1338, '127.0.0.1');
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment