remote/js/lib/RTRemoteTCPTransport.js
/**
   * create tcp connection and open it
   * @return {Promise<RTRemoteTCPTransport>} the promise with RTRemoteTCPTransport
   */
create tcp connection and open it
@return {Promise} the promise with RTRemoteTCPTransport
create tcp connection and open it @return { Promise } the promise with RTRemoteTCPTransport
open() {
    return new Promise((resolve, reject) => {
      const transport = this;
      this.socket = net.connect(transport.port, transport.host, () => {
        logger.info(`new tcp connection to ${transport.host}:${transport.port}`);
        resolve(transport);
      });
      this.socket.on('error', (err) => {
        logger.error(err);
        if (transport.mRunning) { 
          transport.socket.destroy();
        }
        reject(new RTException(err.message));
      });
      this.socket.on('close', () => {
        this.mRunning = false;
        logger.info('a connection closed');
      });
    });
  }
open ( ) { return new Promise ( ( resolve , reject ) => { const transport = this ; this . socket = net . connect ( transport . port , transport . host , ( ) => { logger . info ( ` ${ transport . host } ${ transport . port } ` ) ; resolve ( transport ) ; } ) ; this . socket . on ( 'error' , ( err ) => { logger . error ( err ) ; if ( transport . mRunning ) { transport . socket . destroy ( ) ; } reject ( new RTException ( err . message ) ) ; } ) ; this . socket . on ( 'close' , ( ) => { this . mRunning = false ; logger . info ( 'a connection closed' ) ; } ) ; } ) ; }
create tcp connection and open it
 @return {Promise<RTRemoteTCPTransport>} the promise with RTRemoteTCPTransport
create tcp connection and open it @return { Promise<RTRemoteTCPTransport > } the promise with RTRemoteTCPTransport
// should close socket