python - How do you determine the server disconnection ( case cut off cable ethernet) -
i write code determine connection remote server mysql. here code
import mysqldb def connect_remote(): try: db = mysqldb.connect("192.168.1.7", "root_a","","luan_van") homecoming 1 except mysqldb.operationalerror, e: if e[0] == 2003: homecoming 0 while 1: x = connect_remote() print x
if "start or stop service" wampserver in remote server (192.168.1.7), worked well.
now assumed cutting off cable ethernet connect server, code stop. how identify case?
i don't understand difference between disable mysql , cutting off cable.
please help me. thanks.
the 3 cases can distinguish are:
server on network actively rejecting connections on mysql port server on network not responding @ connection attempts on mysql port server not responding network trafficyou cannot determine more detailed these 3 cases, , distinguishing between 2 , 3 requires work, such pinging server see if responds @ all.
to specific question, there no visible difference between server beingness connected unresponsive (i.e. os crashed, case 3 above) , cable beingness cut. cannot tell difference remote host.
python mysql python-2.7 python-3.x mysql-python
No comments:
Post a Comment