try:
for port in range(50,85):
s = socket.socket(so.AF_INET, so.SOCK_STREAM)
socket.defaulttimeout(1)
result = s.connect_ex((target,port))
if result == 0:
print(f"POrt {port} is open")
s.close()
I'm having a bit of trouble ascertaining as to what exactly the function in the variable of s exactly does. Based on my own understanding, it's needed or else the connect_ex or the regular connect function will not work when giving an IP address and port number. To me, it almost seems like its telling the editor "Alright, you're going to get an IP address and a port number. So when the user uses s with connect, you better accept the IP address and port number arguments".
By the way, the target and port variables were declared in the code with an IP address and a port number. Target being the IP and port being the port number.