Files
sf-op/script/test/CamtoolCheckPort.py
voulot_d f1dc9c7511 Startup
2017-04-06 16:57:17 +02:00

19 lines
438 B
Python

import socket;
url = camtool.getInstance(camtool.getInstances()[0])["stream"]
srv = url[6:url.rfind(":")]
port = int(url[url.rfind(":")+1:])
sock = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
result = sock.connect_ex((srv,port))
if result == 0:
print "Port is open"
elif result == 106:
print "Port is connected"
elif result == 111:
print "Port is not open"
elif result == 111:
print "Error " + result
sock.close()