Threaded Port Scanner using Sockets in Python
Port scanning can be really slow yet, in most cases, is not process intensive. Thus, we can use threading to improve our speed. There can be thousands of possible ports. If it takes 5-15 seconds per port to scan, then we might have a long wait ahead of us without the use of threading.
Threading is a complex topic, but it can be broken down and conceptualized as a methodology where we can tell the computer to do another task if the processor is experiencing idle time. In the case of port scanning, we are spending a lot of time just waiting on the response from the server. While we are waiting, we can do something else. That is what threading is used for.
Example: In this program, we can scan a number of ports in a certain range.
'port is open'
'port is close'
port is close 2
port is close port is close 4
port is closeport is close 1
port is close 6port is close
port is close 8
port is close 9