Sunday 12 March 2017

Is a socket a stream

Using rx-node library, I expect this code to work. But it doesn't recognize a socket as a stream,

stream.pause();
          ^

TypeError: Cannot read property 'pause' of undefined

even though the net documentation appears that it is.

How do I get the stream portion of a net.createServer()

var RxNode = require('rx-node');
var server;
var sSocket;

server =  net.createServer(function (socket) {
  sSocket = socket;
});

var subscription = RxNode.fromStream(sSocket, 'ondata')
    .subscribe(function (x) {process.stdout.write("Got data " + msg + "\n"); });

server.listen(xxxxx, 'xxx.xxx.xx.xxx');



via Ivan

No comments:

Post a Comment