Skip to content

Instantly share code, notes, and snippets.

@inter-coder
Created April 9, 2017 18:44
Embed
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")
@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