From a3ef3fce899e388108657fd72223ea8c6c6cbf53 Mon Sep 17 00:00:00 2001 From: Grahame Bowland Date: Thu, 23 Dec 2004 11:01:21 +0000 Subject: [PATCH] * add door client --- sql-edition/servers/DoorClient.py | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) create mode 100755 sql-edition/servers/DoorClient.py diff --git a/sql-edition/servers/DoorClient.py b/sql-edition/servers/DoorClient.py new file mode 100755 index 0000000..56a4814 --- /dev/null +++ b/sql-edition/servers/DoorClient.py @@ -0,0 +1,23 @@ +#!/usr/bin/python + +from LATClient import LATClient +from select import select +import sys + +def check_door_service(service, test_string="got wombles?"): + latclient = LATClient(service=sys.argv[1]) + latclient.sock.send(test_string) + rfh, wfh = latclient.get_fh() + wfh.write(test_string) + wfh.flush() + rr, wr, er = select([rfh], [], [], 10.0) + if rfh not in rr: return "open" + recv = rfh.read(len(test_string)) + if recv <> test_string: return "error" + return "closed" + +if __name__ == '__main__': + result_codes = { 'open' : 0, 'closed' : 1, 'error' : 2 } + result = check_door_service(sys.argv[1]) + print result + sys.exit(result_codes[result]) -- 2.20.1