Skip to content

Instantly share code, notes, and snippets.

@firephil
Forked from loverdos/par-port-scanner.scala
Last active December 31, 2015 06:29
Show Gist options
  • Save firephil/7947631 to your computer and use it in GitHub Desktop.
Save firephil/7947631 to your computer and use it in GitHub Desktop.
// 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