Skip to content
This repository was archived by the owner on Apr 22, 2023. It is now read-only.
This repository was archived by the owner on Apr 22, 2023. It is now read-only.

TCP.onread block when working with readline on v0.12.2 OSX #25492

@rain1017

Description

@rain1017

I make one tcp request when user input a line, but the TCP response is usually block until making next a few keystrokes. Tcpdump shows that the response packet has reached the client, but TCP.onread does not fired.
I use node v0.12.2, this is only happen in Mac OSX. Ubuntu is OK

echo server

var net = require('net');

var server = net.createServer(function(socket){
    socket.on('data', function(msg){
        console.log('%s', msg);
        socket.write(msg);
    });
});

server.listen(31017, '127.0.0.1');

client

console.log('Type anything then press enter, you should get response from echoServer immediately');
console.log('Sometimes TCP.onread may block until you make next keystroke');

var net = require('net');
var rl = require('readline').createInterface({
    input: process.stdin,
    output: process.stdout,
    terminal : true,
});

var socket = net.createConnection({port : 31017});
socket.on('data', function(buf){
    console.log('=> %s', buf);
});

rl.on('line', function(line){
    socket.write(line);
})
.on('close', function(){
    socket.end();
    process.exit(0);
});

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions