javascript - return value from one function to other -


im using following code , question how should pass port first function seconde,i know if call second function inside first can there other way parctise use?

 portscanner.findaportnotinuse(3000, 3010, '127.0.0.1', function(error, port) {         console.log('available port at: ' + port)     });      http.createserver(function (req, res) {         res.writehead(200, { 'content-type': 'text/plain' });    json.stringify(req.headers, true, 2));         res.end();     }).listen(9033); 

instead of using port 9033 want use value first...

the port scanner method asynchronous, way create server when available port has been determined, when callback function called:

portscanner.findaportnotinuse(3000, 3010, '127.0.0.1', function(error, port) {     console.log('available port at: ' + port)     http.createserver(function (req, res) {       // ...     }).listen(port); }); 

Comments

Popular posts from this blog

powershell Start-Process exit code -1073741502 when used with Credential from a windows service environment -

twig - Using Twigbridge in a Laravel 5.1 Package -

c# - LINQ join Entities from HashSet's, Join vs Dictionary vs HashSet performance -