tcp.js 497 B

1234567891011121314151617181920
  1. 'use strict'
  2. const net = require('net')
  3. const debug = require('debug')('mqttjs:tcp')
  4. /*
  5. variables port and host can be removed since
  6. you have all required information in opts object
  7. */
  8. function streamBuilder (client, opts) {
  9. opts.port = opts.port || 1883
  10. opts.hostname = opts.hostname || opts.host || 'localhost'
  11. const port = opts.port
  12. const host = opts.hostname
  13. debug('port %d and host %s', port, host)
  14. return net.createConnection(port, host)
  15. }
  16. module.exports = streamBuilder