java - a program to print 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
- get material of block bukkit
- Category
- Java
- Title
- how to detect if someone clicks on a jpanel in java
- Category
- Java
- Title
- how to get the max value of an array java
- Category
- Java
- Title
- shortcut to find a class in java project eclipse
- Category
- Java
- Title
- java parse json
- Category
- Java
- Title
- java enum
- Category
- Java
- Title
- java switch multiple values
- Category
- Java
- Title
- java min function
- Category
- Java
- Title
- create jdbc connection in java
- Category
- Java
- Title
- find the day of the week Calendar class in java
- Category
- Java
- Title
- how to show the hex detail of a file in java
- Category
- Java
- Title
- http client java
- Category
- Java
- Title
- java array copy
- Category
- Java
- Title
- sort array java
- Category
- Java
- Title
- android get distance between two locations kotlin
- Category
- Java
- Title
- java script using navigator.useragent to detect the browse
- Category
- Java
- Title
- java shortest if else statement
- Category
- Java
- Title
- how to fill a 2d array in java
- Category
- Java
- Title
- java print type of object
- Category
- Java
- Title
- eclipse does not support logback with spring boot
- Category
- Java
- Title
- java loop through string
- Category
- Java
- Title
- get host from request object java
- Category
- Java
- Title
- change fab image programatically
- Category
- Java
- Title
- int to string java
- Category
- Java
- Title
- restart application programmatically android
- Category
- Java
- Title
- java animated gif example
- Category
- Java
- Title
- inline foreach java
- Category
- Java
- Title
- Java.awt graphics tutorial
- Category
- Java
- Title
- how to exit a for loop in java
- Category
- Java
- Title
- android round double to 2 decimal
- Category
- Java
- Title
- int to binary string java
- Category
- Java
- Title
- processing string to int
- Category
- Java
- Title
- get current day java
- Category
- Java
- Title
- generic method lambda java
- Category
- Java
- Title
- determine if a given binary tree is a valid bst
- Category
- Java
- Title
- runtime java examples
- Category
- Java
- Title
- palindrome function java
- Category
- Java
- Title
- java mockito any string import
- Category
- Java
- Title
- binary to int java
- Category
- Java
- Title
- print out value java
- Category
- Java
- Title
- arraylist java methds
- Category
- Java
- Title
- java getter
- Category
- Java
- Title
- android studio centering textview in relativelayout
- Category
- Java
- Title
- java for each
- Category
- Java
- Title
- Java array hashcode
- Category
- Java
- Title
- calculating the percentile in java
- Category
- Java
- Title
- java array declaration
- Category
- Java
- Title
- java making a screen
- Category
- Java
- Title
- java pass arraylist by value
- Category
- Java
- Title
- how to input in java
- Category
- Java
- Title
- java 8 validate based on pair of strings
- Category
- Java
- Title
- how to take space separated input in java
- Category
- Java
- Title
- java output array lists to file
- Category
- Java
- Title
- how to make an array in java
- Category
- Java
- Title
- random number in range java
- Category
- Java
- Title
- java arraylist
- Category
- Java
- Title
- java delay
- Category
- Java
- Title
- gradle require java version
- Category
- Java
- Title
- raspberry stackexchange how to install the java jdk
- Category
- Java
- Title
- java sort array descending
- Category
- Java
- Title
- android clear specific sharedpreference value
- Category
- Java
- Title
- check java version cmd
- Category
- Java
- Title
- find maven version
- Category
- Java
- Title
- threadsafe singleton pattern in java
- Category
- Java
- Title
- java check for string length
- Category
- Java
- Title
- java bigdecimal compareto
- Category
- Java
- Title
- how to crate a list in java script
- Category
- Java
- Title
- java for each loop
- Category
- Java
- Title
- java how to make a gui
- Category
- Java
- Title
- mutable string in java
- Category
- Java
- Title
- sending a excel in an attachment in email java
- Category
- Java
- Title
- java clear console
- Category
- Java
- Title
- Category
- Java
- Title
- boolean checkbox swing
- Category
- Java
- Title
- java load image
- Category
- Java
- Title
- java how to define a function
- Category
- Java
- Title
- kotlin jsonobject get nested
- Category
- Java
- Title
- capacitor-android. Unfortunately you can't have non-Gradle Java modules and Android-Gradle modules in one project
- Category
- Java
- Title
- java cast duration to long
- Category
- Java
- Title
- initiralizing an arraylist java
- Category
- Java
- Title
- hide elements android
- Category
- Java
- Title
- iterate hashmap java
- Category
- Java
- Title
- enum java
- Category
- Java
- Title
- java script removing first three indexes
- Category
- Java
- Title
- how to format a double in java to 2 decimal places
- Category
- Java
- Title
- print in one line in java
- Category
- Java
- Title
- convert string to localdatetime
- Category
- Java
- Title
- dicom read with java
- Category
- Java
- Title
- how add strings together
- Category
- Java
- Title
- java final meaning
- Category
- Java
- Title
- Java array nested equals
- Category
- Java
- Title
- index 1 out of bound for length 1 java
- Category
- Java
- Title
- filter in list by time java
- Category
- Java
- Title
- take a value from keyboard java
- Category
- Java
- Title
- write an infinite loop java
- Category
- Java
- Title
- how to make one java class inherit from another
- Category
- Java
- Title
- how to compare string in java
- Category
- Java
- Title
- loop an array of objects in java
- Category
- Java
- Title
- ndroid.support.v4.content.FileProvider
- Category
- Java
- Title
- how to pass a float between activities in android studio
- Category
- Java