I am trying to clear the socket before sending the following piece of data:
var net = require('net');
net.createServer(function(socket) {
socket.on('data', function(data) {
console.log(data.toString());
});
}).listen(54358, '127.0.0.1');
var socket = net.createConnection(54358, '127.0.0.1');
socket.setNoDelay(true);
socket.write('mentos');
socket.write('cola');
This, however, does not work, despite the setting setNoDelay, for example. prints "menthol" instead of "mentos \ ncola". How to fix it?
source
share