Skip to content

Commit d997e35

Browse files
Merge pull request #18 from geckogecko/master
fixes #17 single port scan setTimoutMillis does not work
2 parents 1e31aa1 + 145d97b commit d997e35

File tree

1 file changed

+4
-2
lines changed
  • library/src/main/java/com/stealthcopter/networktools/portscanning

1 file changed

+4
-2
lines changed

library/src/main/java/com/stealthcopter/networktools/portscanning/PortScanTCP.java

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22

33
import java.io.IOException;
44
import java.net.InetAddress;
5+
import java.net.InetSocketAddress;
56
import java.net.Socket;
67

78
/**
@@ -12,8 +13,9 @@ public class PortScanTCP {
1213
public static boolean scanAddress(InetAddress ia, int portNo, int timeoutMillis){
1314
Socket s = null;
1415
try {
15-
s = new Socket(ia, portNo);
16-
s.setSoTimeout(timeoutMillis); // This is pointless as we don't get to this point? unless open???
16+
s = new Socket();
17+
s.connect(new InetSocketAddress(ia, portNo), timeoutMillis);
18+
1719
return true;
1820
} catch (IOException e) {
1921
// Don't log anything as we are expecting a lot of these from closed ports.

0 commit comments

Comments
 (0)