Wednesday 18 November 2020

client.on not getting data on single connect

I am using net module to connect client with my server. And here is my code.

        const Net = require('net');

        client = Net.connect(parseInt(port), host, function() {
          console.log('server connected')
        })
        console.log("ooooooooooooooooooooooooooooo")
        client.on('data', function(chunk) {
          let data = chunk.toString()
          console.log(data)
        });
        client.on('error', function(error) {
          console.error('error', error);
        });

The issue is when I connect it with single client it doesn't give me data inside client.on('data' but when I connect it will two or more clients it gets connected and I am getting my data. Someone pls help.



from client.on not getting data on single connect

No comments:

Post a Comment