<trclass="memdesc:ga35e0e6e5e3b7f3818a3ac3600efb8f8f"><tdclass="mdescLeft"> </td><tdclass="mdescRight">Connects to a <code>NATS Streaming Server</code> using the provided options. <br/></td></tr>
<trclass="memdesc:ga2e56a93825e1214a5ab688860e2a8ce6"><tdclass="mdescLeft"> </td><tdclass="mdescRight">Releases the NATS Connection. <br/></td></tr>
<trclass="memdesc:gaea095eec18fdf04e06de16711f8b1a04"><tdclass="mdescLeft"> </td><tdclass="mdescRight">Destroys the connection object. <br/></td></tr>
<p>Attempts to connect to a <code>NATS Streaming Server</code>.</p>
<p>This call is cloning the <aclass="el"href="group__types_group.html#ga13d64411878ba13a6ca39c915f2447c1"title="Way to configure a stanConnection.">stanConnOptions</a> object, if given. Once this call returns, changes made to the <code>options</code> will not have an effect to this connection. The <code>options</code> can however be changed prior to be passed to another <aclass="el"href="group__stan_conn_mgt_group.html#ga35e0e6e5e3b7f3818a3ac3600efb8f8f"title="Connects to a NATS Streaming Server using the provided options.">stanConnection_Connect()</a> call if desired.</p>
<dlclass="section note"><dt>Note</dt><dd>The Streaming connection does not honor the NATS Connection option <aclass="el"href="group__opts_group.html#ga20946800d024b7089e73d63454d1c19f"title="Indicates if initial connect failure should be retried or not.">natsOptions_SetRetryOnFailedConnect()</a>. If you pass NATS Options with this option enabled, no error is returned, but if the connection cannot be established "right away", the connect call will return an error.</dd></dl>
<dlclass="section warning"><dt>Warning</dt><dd>If connecting to a NATS Server v2.2.0+ and there is no Streaming server listening on the connect request subject, this call will return <aclass="el"href="status_8h.html#a36c934157b663b7b5fb5d6609c897c80aab97324e40ccfe1360080c651c330e62"title="No responders were running when the server received the request.">NATS_NO_RESPONDERS</a>, not <aclass="el"href="status_8h.html#a36c934157b663b7b5fb5d6609c897c80ab88994c9ea9889ac4d9d656d62f550ed">NATS_TIMEOUT</a>.</dd></dl>
<dlclass="section see"><dt>See also</dt><dd><aclass="el"href="group__types_group.html#ga13d64411878ba13a6ca39c915f2447c1"title="Way to configure a stanConnection.">stanConnOptions</a></dd>
<dd>
<aclass="el"href="group__stan_conn_mgt_group.html#gaea095eec18fdf04e06de16711f8b1a04"title="Destroys the connection object.">stanConnection_Destroy()</a></dd></dl>
<dlclass="params"><dt>Parameters</dt><dd>
<tableclass="params">
<tr><tdclass="paramname">sc</td><td>the location where to store the pointer to the newly created <aclass="el"href="group__types_group.html#gaf88dca0a18efb5c5e994d265a9f04aec"title="A connection to a NATS Server.">natsConnection</a> object. </td></tr>
<tr><tdclass="paramname">clusterID</td><td>the name of the cluster this connection is for. </td></tr>
<tr><tdclass="paramname">clientID</td><td>the client ID for this connection. Only one connection with this ID will be accepted by the server. Use only a-zA-Z0-9_- characters. </td></tr>
<tr><tdclass="paramname">options</td><td>the options to use for this connection (can be <code>NULL</code>). </td></tr>
<p>This can be used if the application needs to do non streaming messaging but does not want to create a separate NATS Connection.</p>
<p>Obtain a NATS connection from a NATS streaming connection. The NATS connection can be used to perform regular NATS operations, but it is owned and managed by the NATS streaming connection. It cannot be closed, which will happen when the NATS streaming connection is closed.</p>
<dlclass="section note"><dt>Note</dt><dd>For each call to this function, the user must call <aclass="el"href="group__stan_conn_mgt_group.html#ga2e56a93825e1214a5ab688860e2a8ce6"title="Releases the NATS Connection.">stanConnection_ReleaseNATSConnection()</a> when access to the NATS Connection is no longer needed.</dd></dl>
<dlclass="section warning"><dt>Warning</dt><dd>The returned connection cannot be closed, drained nor destroyed. Calling corresponding functions will have no effect or return <aclass="el"href="status_8h.html#a36c934157b663b7b5fb5d6609c897c80a9bb78b4f245d2870040d25c450febd4b">NATS_ILLEGAL_STATE</a>.</dd></dl>
<dlclass="section see"><dt>See also</dt><dd><aclass="el"href="group__stan_conn_mgt_group.html#ga2e56a93825e1214a5ab688860e2a8ce6"title="Releases the NATS Connection.">stanConnection_ReleaseNATSConnection()</a></dd></dl>
<dlclass="params"><dt>Parameters</dt><dd>
<tableclass="params">
<tr><tdclass="paramname">sc</td><td>the pointer to the <aclass="el"href="group__types_group.html#ga9e826493769d23086cfccefe95cdf64c"title="A connection to a NATS Streaming Server.">stanConnection</a> object. </td></tr>
<tr><tdclass="paramname">nc</td><td>the location where to store the pointer of the <aclass="el"href="group__types_group.html#gaf88dca0a18efb5c5e994d265a9f04aec"title="A connection to a NATS Server.">natsConnection</a> object. </td></tr>
<p>This should be paired with the <aclass="el"href="group__stan_conn_mgt_group.html#ga166ec494a55c9b1f9ebafd2294e05ff6"title="Returns the underlying NATS Connection.">stanConnection_GetNATSConnection()</a> call. That is, after getting a reference to the underlying NATS Connection and once that connection is no longer needed, calling this function will allow resources to be properly released when the streaming connection is destroyed.</p>
<p>You would normally call <aclass="el"href="group__stan_conn_mgt_group.html#ga166ec494a55c9b1f9ebafd2294e05ff6"title="Returns the underlying NATS Connection.">stanConnection_GetNATSConnection()</a> and this function only once.</p>
<p>After the last <aclass="el"href="group__stan_conn_mgt_group.html#ga2e56a93825e1214a5ab688860e2a8ce6"title="Releases the NATS Connection.">stanConnection_ReleaseNATSConnection()</a> call is made, you must no longer use the NATS Connection because if <aclass="el"href="group__stan_conn_mgt_group.html#gaea095eec18fdf04e06de16711f8b1a04"title="Destroys the connection object.">stanConnection_Destroy()</a> is called, that could make the pointer to the NATS Connection invalid.</p>
<dlclass="section note"><dt>Note</dt><dd>If the streaming connection is closed/destroyed before the last call to <aclass="el"href="group__stan_conn_mgt_group.html#ga2e56a93825e1214a5ab688860e2a8ce6"title="Releases the NATS Connection.">stanConnection_ReleaseNATSConnection</a>, the pointer to the NATS connection will still be valid, although all calls will fail since the connection is now closed. Calling this function will release the streaming object allowing memory to be freed.</dd></dl>
<dlclass="section see"><dt>See also</dt><dd><aclass="el"href="group__stan_conn_mgt_group.html#ga166ec494a55c9b1f9ebafd2294e05ff6"title="Returns the underlying NATS Connection.">stanConnection_GetNATSConnection</a></dd></dl>
<dlclass="params"><dt>Parameters</dt><dd>
<tableclass="params">
<tr><tdclass="paramname">sc</td><td>the pointer to the <aclass="el"href="group__types_group.html#ga9e826493769d23086cfccefe95cdf64c"title="A connection to a NATS Streaming Server.">stanConnection</a> object. </td></tr>
<p>Closes the connection to the server. This call will release all blocking calls. The connection object is still usable until the call to <aclass="el"href="group__stan_conn_mgt_group.html#gaea095eec18fdf04e06de16711f8b1a04"title="Destroys the connection object.">stanConnection_Destroy()</a>.</p>
<dlclass="section warning"><dt>Warning</dt><dd>See warning about connecting to a NATS Server v2.2.0+ in <aclass="el"href="group__stan_conn_mgt_group.html#ga35e0e6e5e3b7f3818a3ac3600efb8f8f"title="Connects to a NATS Streaming Server using the provided options.">stanConnection_Connect()</a>.</dd></dl>
<dlclass="params"><dt>Parameters</dt><dd>
<tableclass="params">
<tr><tdclass="paramname">sc</td><td>the pointer to the <aclass="el"href="group__types_group.html#ga9e826493769d23086cfccefe95cdf64c"title="A connection to a NATS Streaming Server.">stanConnection</a> object. </td></tr>
<p>Destroys the connection object, freeing up memory. If not already done, this call first closes the connection to the server.</p>
<dlclass="params"><dt>Parameters</dt><dd>
<tableclass="params">
<tr><tdclass="paramname">sc</td><td>the pointer to the <aclass="el"href="group__types_group.html#ga9e826493769d23086cfccefe95cdf64c"title="A connection to a NATS Streaming Server.">stanConnection</a> object. </td></tr>
</table>
</dd>
</dl>
</div>
</div>
</div><!-- contents -->
</div><!-- doc-content -->
<!-- HTML footer for doxygen 1.8.10-->
<!-- start footer part -->
<divid="nav-path"class="navpath"><!-- id is needed for treeview function! -->
<ul>
<liclass="footer">NATS.IO Supported By Synadia Communications Inc.