def do_recv_from_recvmsg_into(socket, buffersize, flags=0): l1 = buffersize // 2 l2 = buffersize - l1 buf1, buf2 = RawByteBuffer(l1), RawByteBuffer(l2) n, data, flag, address = socket.recvmsg_into([buf1, buf2], flags=flags) n1 = min(n, l1) n2 = n - n1 return buf1.as_str()[:n1] + buf2.as_str()[:n2]
def do_recv_from_recvinto(socket, buffersize, flags=0): buf = RawByteBuffer(buffersize) read_bytes = socket.recvinto(buf, buffersize, flags=flags) return buf.as_str()[:read_bytes]