Commit ea3adb92 authored by Michael Graff's avatar Michael Graff
Browse files

exception on close

git-svn-id: svn://bind10.isc.org/svn/bind10/trunk@119 e5f2f494-b856-4b98-b285-d166d9295462
parent c25fdf8d
......@@ -20,6 +20,7 @@ import struct
import Message
class ProtocolError(Exception): pass
class NetworkError(Exception): pass
class Session:
def __init__(self):
......@@ -69,8 +70,8 @@ class Session:
data = self._socket.recv(length)
except:
return None
if not data: # server closed connection
return None
if data == "": # server closed connection
raise ProtocolError("Read of 0 bytes: connection closed")
self._recvbuffer += data
if len(self._recvbuffer) < 4:
......@@ -80,7 +81,12 @@ class Session:
length = self._recvlength - len(self._recvbuffer)
while (length > 0):
data = self._socket.recv(length)
try:
data = self._socket.recv(length)
except:
return None
if data == "": # server closed connection
raise ProtocolError("Read of 0 bytes: connection closed")
self._recvbuffer += data
length -= len(data)
data = self._recvbuffer
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment