code: public void write_ref(final String node, final int[] ids, final int creation) {
          int arity = ids.length;
          if (arity > 3) {
              arity = 3; // max 3 words in ref
          }
  
  	write1(OtpExternal.newRefTag);
  
  	// how many id values
  	write2BE(arity);
  
  	write_atom(node);
  
  	write1(creation & 0x3); // 2 bits
  
  	// first int gets truncated to 18 bits
  	write4BE(ids[0] & 0x3ffff);
  
  	// remaining ones are left as is
  	for (int i = 1; i < arity; i++) {
  	    write4BE(ids[i]);
  	}
      }
docs: Write an Erlang ref to the stream.
  
  @param node
  the nodename.
  
  @param ids
  an array of arbitrary numbers. Only the low order 18 bits of
  the first number will be used. At most three numbers
  will be read from the array.
  
  @param creation
  another arbitrary number. Only the low order 2 bits will be used.