Skip to content

Instantly share code, notes, and snippets.

@inter-coder
Created April 9, 2017 18:44
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save inter-coder/74d3113404ac3ff31255aa8af380d25b to your computer and use it in GitHub Desktop.
Save inter-coder/74d3113404ac3ff31255aa8af380d25b to your computer and use it in GitHub Desktop.
#!/usr/bin/env python
# Determining whether the services are working at a remote location
from socket import *
def DoesServiceExist(host, port):
targetIP = gethostbyname(host)
s = socket(AF_INET, SOCK_STREAM)
s.settimeout(1)
result = s.connect_ex((targetIP,port))
s.close()
if(result == 0) :
return True
return False
#example
if DoesServiceExist("smtp.gmail.com",465):
print("YES mail server is UP")
else:
print("NO mail server is DOWN")
@inter-coder
Copy link
Author

Python code for determining whether the services are working at a remote location

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment