Skip to content

Instantly share code, notes, and snippets.

Created April 12, 2023 19:45
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
Star You must be signed in to star a gist
What would you like to do?
Node.Js Example TCP Server
var net = require('net');
var server = net.createServer(function(socket) {
socket.write('Hello TCP!');
// for testing purposes we handle client side errors
socket.on('error', function(err) {
if (err.code === 'ECONNRESET') {
console.error('Client closed connection');
} else {
server.listen(4444, '');
// run this server with
// node app-tcp.js
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment