Skip to content

Instantly share code, notes, and snippets.

@julianobarbosa
Created February 7, 2020 10:46
Show Gist options
  • Save julianobarbosa/36fb77d3f644f92f69bb3c8bbbc8b43a to your computer and use it in GitHub Desktop.
Save julianobarbosa/36fb77d3f644f92f69bb3c8bbbc8b43a to your computer and use it in GitHub Desktop.
Python, TCP, UDP, Port
import socket
sock = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
sock.settimeout(2) #2 Second Timeout
result = sock.connect_ex(('127.0.0.1',80))
if result == 0:
print 'port OPEN'
else:
print 'port CLOSED, connect_ex returned: '+str(result)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment