[#CConnman-OpenNetworkConnection]
= xref:CConnman.adoc[CConnman]::OpenNetworkConnection
:relfileprefix: ../
:mrdocs:

Open a new P2P connection and initialize it with the PeerManager at `m&lowbar;msgproc`&period;

== Synopsis

Declared in `&lt;net&period;h&gt;`

[source,cpp,subs="verbatim,replacements,macros,-callouts"]
----
&lsqb;&lsqb;requires&lowbar;capability(0x7f950f5fde58, 0x7f950f5fdf18), requires&lowbar;capability(0x7f950ed86688, 0x7f950ed86748), requires&lowbar;capability(0x7f950b48e8f8, 0x7f950b48e9b8), requires&lowbar;capability(0x7f95034d1518, 0x7f95034d15d8), requires&lowbar;capability(0x7f950e20e8e8, 0x7f950e20e9a8), requires&lowbar;capability(0x7f9527746588, 0x7f9527746648), requires&lowbar;capability(0x7f950c323718, 0x7f950c3237d8), requires&lowbar;capability(0x7f950c23f348, 0x7f950c23f408), requires&lowbar;capability(0x7f95018b8af8, 0x7f95018b8bb8), requires&lowbar;capability(0x7f950bd909a8, 0x7f950bd90a68), requires&lowbar;capability(0x7f95065c80a8, 0x7f95065c8168)&rsqb;&rsqb;
bool
OpenNetworkConnection(
    xref:CAddress.adoc[CAddress] const& addrConnect,
    bool fCountFailure,
    xref:CountingSemaphoreGrant.adoc[CountingSemaphoreGrant&lt;&gt;]&& grant&lowbar;outbound,
    char const* pszDest,
    xref:ConnectionType.adoc[ConnectionType] conn&lowbar;type,
    bool use&lowbar;v2transport,
    std::optional&lt;Proxy&gt; const& proxy&lowbar;override);
----

== Return Value

whether the connection was opened successfully&period;

== Parameters

[cols="1,4"]
|===
| Name| Description
| *addrConnect* [in]
| Address to connect to, if `pszDest` is `nullptr`&period;
| *fCountFailure* [in]
| Increment the number of connection attempts to this address in Addrman&period;
| *grant&lowbar;outbound* [in]
| Take ownership of this grant, to be released later when the connection is closed&period;
| *pszDest* [in]
| Address to resolve and connect to&period;
| *conn&lowbar;type* [in]
| Type of the connection to open, must not be `ConnectionType&colon;&colon;INBOUND`&period;
| *use&lowbar;v2transport* [in]
| Use P2P encryption, (aka V2 transport, BIP324)&period;
| *proxy&lowbar;override* [in]
| Optional proxy to use and override normal proxy selection&period;
|===


[.small]#Created with https://www.mrdocs.com[MrDocs]#
