lib/httpServer/transports/http/index.js
function bindToFile(filePath, cb) {
	// resolve the path and shorten it to avoid long-path bind errors
	// NOTE: only do so on non-windows systems

	if (process.platform !== 'win32') {
		filePath = pathRelative(process.cwd(), pathResolve(filePath));
	}

	function callback(error) {
		server.removeListener('error', callback);

		if (error) {
			if (error.code === 'EADDRINUSE') {
				error.message =
					filePath + ' already exists. Perhaps the server did not shut down ' +
					'cleanly. Try removing the file and starting again. (' + error.code + ')';
			} else {
				error.message = 'Error while binding to ' + filePath + ' (' + error.code + ')';
			}

			return cb(error);
		}

		logger.notice('HTTP Server bound to', filePath);

		return cb();
	}

	// listen() can throw, despite the error listener
	// this happens in cluster mode if the stdio channels have been closed by the master

	server.on('error', callback);

	try {
		server.listen(filePath, function (error) {
			if (error) {
				return callback(error);
			}

			fs.chmod(filePath, parseInt('777', 8), callback);
		});
	} catch (error) {
		// listen() can throw, despite the error listener
		// this happens in cluster mode if the stdio channels have been closed by the master

		setImmediate(function () {
			callback(error);
		});
	}
}
function bindToFile(filePath, cb) {
	// resolve the path and shorten it to avoid long-path bind errors
	// NOTE: only do so on non-windows systems

	if (process.platform !== 'win32') {
		filePath = pathRelative(process.cwd(), pathResolve(filePath));
	}

	function callback(error) {
		server.removeListener('error', callback);

		if (error) {
			if (error.code === 'EADDRINUSE') {
				error.message =
					filePath + ' already exists. Perhaps the server did not shut down ' +
					'cleanly. Try removing the file and starting again. (' + error.code + ')';
			} else {
				error.message = 'Error while binding to ' + filePath + ' (' + error.code + ')';
			}

			return cb(error);
		}

		logger.notice('HTTP Server bound to', filePath);

		return cb();
	}

	// listen() can throw, despite the error listener
	// this happens in cluster mode if the stdio channels have been closed by the master

	server.on('error', callback);

	try {
		server.listen(filePath, function (error) {
			if (error) {
				return callback(error);
			}

			fs.chmod(filePath, parseInt('777', 8), callback);
		});
	} catch (error) {
		// listen() can throw, despite the error listener
		// this happens in cluster mode if the stdio channels have been closed by the master

		setImmediate(function () {
			callback(error);
		});
	}
}
function bindToFile ( filePath , cb ) { // resolve the path and shorten it to avoid long-path bind errors // NOTE: only do so on non-windows systems if ( process . platform !== 'win32' ) { filePath = pathRelative ( process . cwd ( ) , pathResolve ( filePath ) ) ; } function callback ( error ) { server . removeListener ( 'error' , callback ) ; if ( error ) { if ( error . code === 'EADDRINUSE' ) { error . message = filePath + ' already exists. Perhaps the server did not shut down ' + 'cleanly. Try removing the file and starting again. (' + error . code + ')' ; } else { error . message = 'Error while binding to ' + filePath + ' (' + error . code + ')' ; } return cb ( error ) ; } logger . notice ( 'HTTP Server bound to' , filePath ) ; return cb ( ) ; } // listen() can throw, despite the error listener // this happens in cluster mode if the stdio channels have been closed by the master server . on ( 'error' , callback ) ; try { server . listen ( filePath , function ( error ) { if ( error ) { return callback ( error ) ; } fs . chmod ( filePath , parseInt ( '777' , 8 ) , callback ) ; } ) ; } catch ( error ) { // listen() can throw, despite the error listener // this happens in cluster mode if the stdio channels have been closed by the master setImmediate ( function ( ) { callback ( error ) ; } ) ; } }
functions for listening on port or socket file
functions for listening on port or socket file