cplusplus.com
C++ : Forum : UNIX/Linux Programming : How to use poll() with non-blocking sock
 
cplusplus.com
Information
Documentation
Reference
Articles
Forum
Forum
Beginners
Windows Programming
UNIX/Linux Programming
General C++ Programming
Lounge
Jobs


post How to use poll() with non-blocking sockets

tnjones (38)
I have this project where I have to implement a simple port scanner in C++ for Linux. The program should take as input a target IP address, beginning port number, and ending port number. After recieving the above info, the program should display a list of open ports. I finally got it working but it takes a very long time to search a wide range of ports(100 to 1000). I was told that the run time would greatly decrease if I had several non -blocking sockets and apply poll() or use multi-threading(which is dificult so I heard). With this in mind, I am trying to find out how to open several non -blocking sockets and apply poll().However, I am confused about how to do this. Currently, after a user enters ip and the start and end ports I open a socket inside a for loop(goes from the start port to end port). Any advice/example would greatly be appreciated.
Topic archived. No new replies allowed.