java - get open ports
Java
import java.io.IOException;
import java.net.Socket;
public class App {
public static void main(String[] args) {
Socket tempSocket = new Socket(); // Initialize
boolean isOpened;
// Loop through all the 65536 ports
for (int port = 0; port < 65536; port++) {
// We will assume the current port is opened unless
// An exception occurs
isOpened = true;
try {
// Let's try connecting
tempSocket = new Socket("127.0.0.1", port);
}
catch (IOException e) {
// If an IOException occurs, then port is closed
isOpened = false;
}
finally {
// Close the socket to save resources
tempSocket.close();
}
// If port is opened print a message to the console
if (isOpened) {
String message = String.format("port %d is open", port);
System.out.println(message);
}
}
}
}
Also in Java:
- Title
- java 8 random string generator
- Category
- Java
- Title
- java convert a string to char[]
- Category
- Java
- Title
- using class in java
- Category
- Java
- Title
- getordefault java
- Category
- Java
- Title
- java split array into two
- Category
- Java
- Title
- java for each
- Category
- Java
- Title
- read a mail and its content in java mail api
- Category
- Java
- Title
- javafx detect collision
- Category
- Java
- Title
- java how to iterate through a arraylist
- Category
- Java
- Title
- how to create a thread local variable in java
- Category
- Java
- Title
- difference between compile and execute in java
- Category
- Java
- Title
- array in java
- Category
- Java
- Title
- java flood fill
- Category
- Java
- Title
- not equal to java
- Category
- Java
- Title
- change the value in a hashtable java
- Category
- Java
- Title
- java remove double spaces
- Category
- Java
- Title
- protect java
- Category
- Java
- Title
- declare bufferedreader java
- Category
- Java
- Title
- array rotation program in java
- Category
- Java
- Title
- java hashmap syntax
- Category
- Java
- Title
- remove item from arraylist in java
- Category
- Java
- Title
- array null pointer java
- Category
- Java
- Title
- date to string java
- Category
- Java
- Title
- java lambda list of objects cast
- Category
- Java
- Title
- java 8 group a collections by 2 property
- Category
- Java
- Title
- bukkit java get player count
- Category
- Java
- Title
- how do i print text in java
- Category
- Java
- Title
- how to calculate exponential in java
- Category
- Java
- Title
- java string reverse
- Category
- Java
- Title
- java pass arraylist by value
- Category
- Java
- Title
- java method overriding
- Category
- Java
- Title
- calculating the percentile in java
- Category
- Java
- Title
- java optional to collection
- Category
- Java
- Title
- primitive and non primitive data types in java
- Category
- Java
- Title
- java read each lines in file
- Category
- Java
- Title
- find a substring in a string java
- Category
- Java
- Title
- how to find the divisors of a number in java
- Category
- Java
- Title
- add video in bootstrap
- Category
- Java
- Title
- spigot title
- Category
- Java
- Title
- java logical operator
- Category
- Java
- Title
- how to add a keylistener to a jframe
- Category
- Java
- Title
- adb: command not found
- Category
- Java
- Title
- check if string is null or empty java
- Category
- Java
- Title
- diagonal difference hackerrank solution in java 8 using list
- Category
- Java
- Title
- java call another constructor
- Category
- Java
- Title
- java main method
- Category
- Java
- Title
- recursive function for fibonacci series in java javascript
- Category
- Java
- Title
- java startActivity crash
- Category
- Java
- Title
- pass list to intent in android java
- Category
- Java
- Title
- snackbar not showing with bottom nav
- Category
- Java
- Title
- how to make one java class inherit from another
- Category
- Java
- Title
- java create folder
- Category
- Java
- Title
- binary to int java
- Category
- Java
- Title
- java observable to observer
- Category
- Java
- Title
- remove spaces at beginning and end of string java
- Category
- Java
- Title
- annotation spring notnull
- Category
- Java
- Title
- trim() and split() in java
- Category
- Java
- Title
- string to arraylist convert java
- Category
- Java
- Title
- java how to make a gui
- Category
- Java
- Title
- java projects
- Category
- Java
- Title
- do while loop java
- Category
- Java
- Title
- comparable on a generic class java
- Category
- Java
- Title
- random boolean java
- Category
- Java
- Title
- java - get open ports
- Category
- Java
- Title
- java permutation
- Category
- Java
- Title
- java generate list of random element
- Category
- Java
- Title
- iterate map in java
- Category
- Java
- Title
- how to create an abstract method in java
- Category
- Java
- Title
- how to declare array java
- Category
- Java
- Title
- convert array of int to arraylist java
- Category
- Java
- Title
- restart application programmatically android
- Category
- Java
- Title
- java enum
- Category
- Java
- Title
- jsonobject to java object
- Category
- Java
- Title
- android get distance between two locations kotlin
- Category
- Java
- Title
- how to delete an element from an array in java
- Category
- Java
- Title
- java variable declaration
- Category
- Java
- Title
- how to iterate list in java selenium
- Category
- Java
- Title
- android create notification
- Category
- Java
- Title
- java how to read a text file
- Category
- Java
- Title
- print hashtable in java
- Category
- Java
- Title
- Java.awt graphics tutorial
- Category
- Java
- Title
- java mockito print called methods
- Category
- Java
- Title
- run spring boot application command line
- Category
- Java
- Title
- java how to initialize an array
- Category
- Java
- Title
- how to count number of words in a string
- Category
- Java
- Title
- java random char a-z
- Category
- Java
- Title
- java prev_permutation
- Category
- Java
- Title
- entre clavier java
- Category
- Java
- Title
- color from hex code flutter
- Category
- Java
- Title
- java cast duration to long
- Category
- Java
- Title
- android studio centering textview in relativelayout
- Category
- Java
- Title
- java open file
- Category
- Java
- Title
- fastapi list query parameter
- Category
- Java
- Title
- android switch on change
- Category
- Java
- Title
- how to exit a for loop in java
- Category
- Java
- Title
- replace regex group() java
- Category
- Java
- Title
- number of matches regex java
- Category
- Java
- Title
- how to make an array in java
- Category
- Java
- Title
- java how to make a string lowercase
- Category
- Java
- Title
- how to add an object to a list of objects in java
- Category
- Java