def send(term, stream):
    """Write an Erlang term to an output stream."""
    payload = erlang.term_to_binary(term)
    header = struct.pack('!I', len(payload))
    stream.write(header)
    stream.write(payload)
    stream.flush()
Write an Erlang term to an output stream.