Created
April 2, 2013 09:50
-
-
Save loverdos/5291143 to your computer and use it in GitHub Desktop.
Parallel port scanner in Scala
This file contains 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
// Parallel port scanner using parallel collections (just for the side-effect) | |
// @author = @loverdos | |
(1 to 65536).par.map { case port ⇒ | |
try { | |
val socket = new java.net.Socket("127.0.0.1", port) | |
socket.close() | |
println(port) | |
port | |
} catch { | |
case _: Throwable ⇒ -1 | |
} | |
}.toSet |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment