Example #1
0
  /**
   * Send the cookie first, then the our port number. If the cookie doesn't match the receiver's
   * cookie, the receiver will reject the connection and close it.
   */
  protected void sendLocalAddress(Address local_addr) throws Exception {
    try {
      // write the cookie
      out.write(cookie, 0, cookie.length);

      // write the version
      out.writeShort(Version.version);
      out.writeShort(local_addr.size()); // address size
      local_addr.writeTo(out);
      out.flush(); // needed ?
      updateLastAccessed();
    } catch (Exception ex) {
      server.socket_factory.close(this.sock);
      throw ex;
    }
  }