diff options
author | Dmitry Moiseev <m0sia@m0sia.ru> | 2013-11-18 11:26:21 +0600 |
---|---|---|
committer | Dmitry Moiseev <m0sia@m0sia.ru> | 2013-11-18 11:26:21 +0600 |
commit | 25c1c96ac741c54f8ff91b43e717eecc21253e88 (patch) | |
tree | 83953ef5c356d110fdbab56be2511ac4b506d439 | |
parent | af533148a958014b95120bc95127d2150d859ca5 (diff) | |
download | pyParrotZikTCP-25c1c96ac741c54f8ff91b43e717eecc21253e88.tar.xz pyParrotZikTCP-25c1c96ac741c54f8ff91b43e717eecc21253e88.zip |
fixed exception on connection lost
Diffstat (limited to '')
-rw-r--r-- | ParrotZik.py | 8 |
1 files changed, 6 insertions, 2 deletions
diff --git a/ParrotZik.py b/ParrotZik.py index b7f5dd7..f86ca97 100644 --- a/ParrotZik.py +++ b/ParrotZik.py @@ -13,7 +13,8 @@ class ParrotZik(object): if len(service_matches) == 0: print "Couldn't find Parrot Zik" - return False + self.sock ="" + return first_match = service_matches[0] port = first_match["port"] @@ -87,7 +88,10 @@ class ParrotZik(object): return self.sendMessage(message) def sendMessage(self,message): - self.sock.send(str(message)) + try: + self.sock.send(str(message)) + except: + self.sock ="" data = self.sock.recv(7) len = struct.unpack('B', data[1])[0] data = self.sock.recv(1024) |