Create a gist now

Instantly share code, notes, and snippets.

What would you like to do?
#!/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")
Owner

inter-coder commented Apr 9, 2017

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