I did it, by the way it is giving error, because port 80 is open and it returns as closed
import socket
s = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
server = '201.27.188.138'
port = '80'
def MeuScanDaorao(port):
try:
s.connect((server, port))
return True
except:
return False
if MeuScanDaorao(port):
print(MeuScanDaorao('aaa'))
else:
print('Ta fechada')
This is my code below, I do not understand why the one above does not. Python is very cool, I need to learn only
import socket
s = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
server = '201.27.188.138'
def MeuScanDaorao(port):
try:
s.connect((server, port))
return True
except:
return False
for x in range(80,81):
if MeuScanDaorao(x):
print('Porta', x, 'ta aberta')
else:
print('Porta', x,'fechada')