constructor(frontend) { process.title = 'ndb/ndd_service'; this._disconnectPromise = new Promise(resolve => process.once('disconnect', () => resolve(DebugState.PROCESS_DISCONNECT))); this._connected = new Set(); this._frontend = frontend; const pipePrefix = process.platform === 'win32' ? '\\\\.\\pipe\\' : os.tmpdir(); const pipeName = `node-ndb.${process.pid}.sock`; this._pipe = path.join(pipePrefix, pipeName); const server = net.createServer(socket => { socket.on('data', async d => { const runSession = await this._startSession(JSON.parse(d), frontend); socket.write('run'); runSession(); }); socket.on('error', e => caughtErrorDebug(e)); }).listen(this._pipe); server.unref(); }
stop(force: boolean, cb: () => void) { this.switcher.close(); this.listeningServer.close(); process.nextTick(cb); }
stop() { this.server.close(); process.exit(0); }
constructor(server: net.Server, opts: HybridSwitcherOptions) { super(); this.server = server; this.wsprocessor = new WSProcessor(); this.tcpprocessor = new TCPProcessor(opts.closeMethod); this.id = 1; this.timeout = (opts.timeout || DEFAULT_TIMEOUT) * 1000; this.setNoDelay = opts.setNoDelay; if (!opts.ssl) { this.server.on('connection', this.newSocket.bind(this)); } else { this.server.on('secureConnection', this.newSocket.bind(this)); this.server.on('clientError', function (e, tlsSo) { logger.warn('an ssl error occured before handshake established: ', e); tlsSo.destroy(); }); } this.wsprocessor.on('connection', this.emit.bind(this, 'connection')); this.tcpprocessor.on('connection', this.emit.bind(this, 'connection')); this.state = ST_STARTED; }
this.tcpServer.listen(this.port); process.nextTick(cb);
close() { this.server.close(); }
server.on('error', function(err) { if (err.code == 'EADDRINUSE') { console.log('Address in use, exiting...'); } else { console.log('Unknown error setting up proxy: ' + err); } process.exit(1); });
require('net').createServer( function (socket) { tcpConnect = true; /* jshint unused: false*/ socket.on('data', function (data) { tcpDataReceive = true; }); socket.on('end', function (data) { tcpServerEnd = true; }); }).listen(8991);