[#NATPMPRequestPortMap]
= NATPMPRequestPortMap
:mrdocs:

Try to open a port using RFC 6886 NAT&hyphen;PMP&period; IPv4 only&period;

== Synopsis

Declared in `&lt;common&sol;pcp&period;h&gt;`

[source,cpp,subs="verbatim,replacements,macros,-callouts"]
----
std::variant&lt;MappingResult, MappingError&gt;
NATPMPRequestPortMap(
    xref:CNetAddr.adoc[CNetAddr] const& gateway,
    uint16&lowbar;t port,
    uint32&lowbar;t lifetime,
    xref:CThreadInterrupt.adoc[CThreadInterrupt]& interrupt,
    int num&lowbar;tries = 3,
    std::chrono::milliseconds timeout&lowbar;per&lowbar;try = std&colon;&colon;chrono&colon;&colon;milliseconds(1000));
----

== Description

&ast; gateway&colon; Destination address for PCP requests (usually the default gateway)&period; &ast; port&colon; Internal port, and desired external port&period; &ast; lifetime&colon; Requested lifetime in seconds for mapping&period; The server may assign as shorter or longer lifetime&period; A lifetime of 0 deletes the mapping&period; &ast; num&lowbar;tries&colon; Number of tries in case of no response&period;

Returns the external&lowbar;ip&colon;external&lowbar;port of the mapping if successful, otherwise a MappingError&period;

== Return Value

The mapping result on success, otherwise a MappingError&period;

== Parameters

[cols="1,4"]
|===
| Name| Description
| *gateway*
| Destination address for requests (usually the default gateway)&period;
| *port*
| Internal port, and desired external port&period;
| *lifetime*
| Requested lifetime in seconds&semi; 0 deletes the mapping&period;
| *interrupt*
| Interruption signal used to abort while waiting for a response&period;
| *num&lowbar;tries*
| Number of attempts in case of no response&period;
| *timeout&lowbar;per&lowbar;try*
| Time to wait for a response on each attempt&period;
|===


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