Hey,
I have a readable Stream which wraps a socket:
function SocketWrapper(socket, options) {
this.socket = socket;
this.socket.on('readable', function() {
self.read();
});
this.socket.on('end', function() {
self.push(null);
});
stream.Readable.call(this, options);
}
util.inherits(SocketWrapper, stream.Readable);
SocketWrapper.prototype._read = function(size) {
var chunk = this.socket.read();
if (chunk === null)
return this.push('');
this.push(chunk);
};
I would now like to read data from the SocketWrapper:
var swrapper = new SocketWrapper(socket);
swrapper.on('readable', function() {
console.log('data', swrapper.read());
});
Unfortunately I always get logged null and never a buffer.
I also logged the whole swrapper object to check out how _readableState
looks like
and the buffer really gets cleared on the readable method but the read
method itself does not return anything.
What did I forget?
--
--
Job Board: http://jobs.nodejs.org/
Posting guidelines:
https://github.com/joyent/node/wiki/Mailing-List-Posting-Guidelines
You received this message because you are subscribed to the Google
Groups "nodejs" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/nodejs?hl=en?hl=en
---
You received this message because you are subscribed to the Google Groups
"nodejs" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
For more options, visit https://groups.google.com/groups/opt_out.