code: 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.serializedSize()); // address size
              local_addr.writeTo(out);
              out.flush(); // needed ?
              updateLastAccessed();
          }
          catch(Exception ex) {
              server.socket_factory.close(this.sock);
              connected=false;
              throw ex;
          }
      }
docs: 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.