diff --git a/examples/readable.js b/examples/readable.js index 8bab16e..72ab3fa 100644 --- a/examples/readable.js +++ b/examples/readable.js @@ -2,7 +2,14 @@ const fs = require('fs'); const dest = fs.createWriteStream('./output'); const { SRTReadStream } = require('../index.js'); -const srt = new SRTReadStream('0.0.0.0', 1234); -srt.listen(readStream => { - readStream.pipe(dest); -}); \ No newline at end of file +if (process.argv[2] === "listener") { + const srt = new SRTReadStream('0.0.0.0', 1234); + srt.listen(readStream => { + readStream.pipe(dest); + }); +} else { + const srt = new SRTReadStream('127.0.0.1', 1234); + srt.connect(readStream => { + readStream.pipe(dest); + }); +} \ No newline at end of file diff --git a/src/stream.js b/src/stream.js index ef624fd..2648c38 100644 --- a/src/stream.js +++ b/src/stream.js @@ -33,7 +33,8 @@ class SRTReadStream extends Readable { } connect(cb) { - this.fd = this.srt.connect(this.socket, address, port); + this.srt.connect(this.socket, this.address, this.port); + this.fd = this.socket; if (this.fd) { cb(this); }