<h2class="title"style="clear: both"><aid="rep_newsite"></a>Connecting to a new site</h2>
</div>
</div>
</div>
<p>To add a new site to the replication group all that is needed
is for the client member to join. Berkeley DB will perform an
internal initialization from the master to the client automatically
and will run recovery on the client to bring it up to date
with the master.</p>
<p>For Base API applications, connecting to a
new site in the replication group happens whenever the
<ahref="../api_reference/C/repmessage.html"class="olink">DB_ENV->rep_process_message()</a> method returns <ahref="../api_reference/C/repmessage.html#repmsg_DB_REP_NEWSITE"class="olink">DB_REP_NEWSITE</a>. The application
should assign the new site a local environment ID number, and all future
messages from the site passed to <ahref="../api_reference/C/repmessage.html"class="olink">DB_ENV->rep_process_message()</a> should include that
environment ID number. It is possible, of course, for the application
to be aware of a new site before the return of <ahref="../api_reference/C/repmessage.html"class="olink">DB_ENV->rep_process_message()</a> (for
example, applications using connection-oriented protocols are likely to
detect new sites immediately, while applications using broadcast
protocols may not).</p>
<p>Regardless, in applications supporting the dynamic addition of database
environments to replication groups, environments joining an existing
replication group may need to provide contact information. (For
example, in an application using TCP/IP sockets, a DNS name or IP
address might be a reasonable value to provide.) This can be done using
the <spanclass="bold"><strong>cdata</strong></span> parameter to the <ahref="../api_reference/C/repstart.html"class="olink">DB_ENV->rep_start()</a> method. The information
referenced by <spanclass="bold"><strong>cdata</strong></span> is wrapped in the initial contact message
sent by the new environment, and is provided to the existing members of
the group using the <spanclass="bold"><strong>rec</strong></span> parameter returned by <ahref="../api_reference/C/repmessage.html"class="olink">DB_ENV->rep_process_message()</a>.
If no additional information was provided for Berkeley DB to forward to the
existing members of the group, the <spanclass="bold"><strong>data</strong></span> field of the <spanclass="bold"><strong>rec</strong></span>
parameter passed to the <ahref="../api_reference/C/repmessage.html"class="olink">DB_ENV->rep_process_message()</a> method will be NULL after