[python]connect_ex() from socket library

I am about to write my own portscanner instead of using the python-nmap. The built-in python socket library has this connect_ex() function, from the documentation it says connect_ex() returns 0 if the operation is successful otherwise will return a value to errno variable. What this means is if the connection is successful the method connect_ex() returns 0 otherwise some value will be returned.

s1This code attempts to connect to a host by port 443, however the host does not have 443 hence it returns this:

So I tried another port which is available:
s3because 445 is available the code returns this:


Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s