Files
sf-op/script/test/CamtoolCheckPort.py
2021-08-17 14:06:14 +02:00

19 lines
438 B
Python
Executable File

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()