'Wrapper around pyOpenSSL\'s Connection.recv
PyOpenSSL doesn\'t return "" on error like socket.recv does,
instead it throws a SSL.ZeroReturnError or (-1, "Unexpected EOF") erorrs.
Wrap recv so we don\'t have to deal with that noise.'

def recv(self, size, flags=0):

    if ((flags & socket.MSG_PEEK) == 0):
        return self._recv(size)
    if (len(self.buffer) >= size):
        return self.buffer[:size]
    try:
        self.buffer += self._recv((size - len(self.buffer)))
    except SSL.WantReadError:
        pass
    return self.buffer[:size]
