Created
November 25, 2014 13:45
-
-
Save ciwolsey/d449d2a692e06e3b8266 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| var Fiber = require('fibers'); | |
| var Future = require('fibers/future'); | |
| var ping = require('ping'); | |
| function hostCheck(host){ | |
| var future = new Future; | |
| console.log("ping"); | |
| ping.sys.probe(host, function(alive){ | |
| future.return(alive); | |
| console.log("pong"); | |
| }); | |
| return future.wait(); | |
| } | |
| var a = function go(){ | |
| hostCheck("youtube.com"); | |
| hostCheck("youtube.com"); | |
| hostCheck("youtube.com"); | |
| hostCheck("youtube.com"); | |
| hostCheck("youtube.com"); | |
| hostCheck("youtube.com"); | |
| hostCheck("youtube.com"); | |
| hostCheck("youtube.com"); | |
| hostCheck("youtube.com"); | |
| hostCheck("youtube.com"); | |
| }.future(); | |
| a(); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| ciwolsey@parabola:~/projects/hellonode$ node index2.js | |
| ping | |
| ping | |
| pong | |
| ping | |
| pong | |
| ping | |
| pong | |
| ping | |
| pong | |
| ping | |
| pong | |
| ping | |
| pong | |
| ping | |
| pong | |
| ping | |
| pong | |
| ping | |
| pong | |
| pong |
should go
ping > ping > ping > ping > ping > ping > ping > ping > ping > ping
pong >pong >pong >pong >pong >pong >pong >pong >pong
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
try this man