def receive(self, socket, n):
try:<EOL><INDENT>new_extent = self._extent + n<EOL>overflow = new_extent - len(self._data)<EOL>if overflow > <NUM_LIT:0>:<EOL><INDENT>if self._recycle():<EOL><INDENT>return self.receive(socket, n)<EOL><DEDENT>self._view = None<EOL>data = socket.recv(n)<EOL>data_size = len(data)<EOL>new_extent = self._extent + data_size<EOL>self._data[self._extent:new_extent] = data<EOL>self._view = memoryview(self._data)<EOL><DEDENT>else:<EOL><INDENT>data_size = socket.recv_into(self._view[self._extent:new_extent])<EOL>new_extent = self._extent + data_size<EOL><DEDENT>self._extent = new_extent<EOL>return data_size<EOL><DEDENT>except KeyboardInterrupt:<EOL><INDENT>return -<NUM_LIT:1><EOL><DEDENT>
Note: may modify buffer size, should error if frame exists