Skip to content

AnastasiosF/Kotlin-Simple-Port-Scanner

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

3 Commits
 
 
 
 

Repository files navigation

Kotlin-Simple-Port-Scanner

Simple port Scanner

import java.io.IOException
import java.net.InetAddress
import java.net.Socket

fun main() {
    val host = "localhost"
    val inetAddress = InetAddress.getByName(host)
    val hostName = inetAddress.hostName
    for (port in 0..65535) {
        try {
            val socket = Socket(hostName, port)
            val text = "$hostName is listening on port $port"
            println(text)
            socket.close()
        } catch (e: IOException) { // empty catch block
        }
    }
}

About

Simple port Scanner

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages