1
I did so, by the way he’s making a mistake, because door 80 is open and he 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 my code from the bottom works, I do not understand why the top 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')
What would be
MeuScanDaorao('aaa')
?– Woss
Just to show him if the door’s open
– Estagiário
But you are calling the function to connect on the server by port
'aaa'
? It didn’t make much sense.– Woss
That’s just the print kkk
– Estagiário
Yes, even if it is a print, the function will be called and will continue to make no sense. It would not be only
print("aaa")
?– Woss
o ' and " do not change at all, the two are to comment, if you had written with nothing, just inside the paratenses, then yes it would print the function itself
– Estagiário