Win a copy of Cross-Platform Desktop Applications: Using Node, Electron, and NW.js this week in the JavaScript forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

port scanning  RSS feed

 
himaks shah
Greenhorn
Posts: 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
i want to do port scanning in java
that i want to listen which ports are open ,closed or blocked
how can i do this using java?
 
Ulf Dittmer
Rancher
Posts: 42972
73
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You could try to open Socket connections to each port you're interested in. You probably want to make the code multi-threaded so you can open connections to many ports (or machines) at the same time, because it'll take a while for the connection attempts to time out if nothing is listening on that port.

Keep in mind that port scanning is considered a hostile (and possibly illegal) thing to do if you don't have permission to do it.

What do you mean by a "blocked" port?
 
Ernest Friedman-Hill
author and iconoclast
Sheriff
Posts: 24217
38
Chrome Eclipse IDE Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Java is a pretty poor choice for this, actually; ideally you'd want to send individual specially-crafted packets and look at the responses. Java won't give you that kind of control.
 
It is sorta covered in the JavaRanch Style Guide.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!