-
-
Save creationix/09d886b6d7dbb5c3fdb6 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var net = require('net'); | |
var server = net.createServer(function (socket) { | |
console.log("connection"); | |
socket.on('data', function (data) { console.log('SERVER data', data);}); | |
socket.on('end', function () { console.log('SERVER end'); server.close(); }); | |
socket.on('close', function () { console.log('SERVER close'); }); | |
console.log("SERVER sending"); | |
socket.write("."); | |
console.log("SERVER ending"); | |
socket.end(); | |
}); | |
server.listen(1337, function () { | |
console.log("Server at 1337"); | |
var socket = net.createConnection({port: 1337, allowHalfOpen: true}, function () { | |
socket.write("."); | |
console.log("CLient sending data"); | |
}); | |
socket.on('data', function (data) { console.log('CLIENT data', data); }); | |
socket.on('end', function (end) { console.log('CLIENT end');}); | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Here is output when I test this on my linux machine: