Kaydet (Commit) 456bfa1c authored tarafından Aanand Prasad's avatar Aanand Prasad

Reorder socket.py methods

Signed-off-by: 's avatarAanand Prasad <aanand.prasad@gmail.com>
üst 472a7ffc
......@@ -28,6 +28,19 @@ def read_socket(socket, n=4096):
raise
def read_data(socket, n):
"""
Reads exactly n bytes from socket
"""
data = six.binary_type()
while len(data) < n:
next_data = read_socket(socket, n - len(data))
if not next_data:
raise SocketError("Unexpected EOF")
data += next_data
return data
def next_packet_size(socket):
"""
Returns the size of the next frame of data waiting to be read from socket,
......@@ -44,19 +57,6 @@ def next_packet_size(socket):
return actual
def read_data(socket, n):
"""
Reads exactly n bytes from socket
"""
data = six.binary_type()
while len(data) < n:
next_data = read_socket(socket, n - len(data))
if not next_data:
raise SocketError("Unexpected EOF")
data += next_data
return data
def read_iter(socket):
"""
Returns a generator of frames read from socket
......
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