Class Client
Communicates with a NAT that speaks the Port Mapping Protocol.
Inherited Members
Namespace: Makaretu.Nat.Pmp
Assembly: Makaretu.Nat.dll
Syntax
public class Client : NatClient
Remarks
Automates the process of creating Network Address Translation(NAT) port mappings. Allows retrieving the external IPv4 address of a NAT gateway, thus allowing a client to make its external IPv4 address and port known to peers that may wish to communicate with it.
NAT-PMP is superseded by the IETF Standards Track RFC "Port Control Protocol (PCP)", which builds on NAT-PMP and uses a compatible packet format, but adds a number of significant enhancements.
Constructors
| Improve this Doc View SourceClient(IPAddress)
Creates a new instance of the NAT-PMP Client class with the specified IP Address of the NAT.
Declaration
public Client(IPAddress address)
Parameters
Type | Name | Description |
---|---|---|
IPAddress | address | The IP address of the NAT server. |
Fields
| Improve this Doc View SourceProtocolVersion
The version of the NAT-PMP.
Declaration
public const int ProtocolVersion = 0
Field Value
Type | Description |
---|---|
Int32 |
Methods
| Improve this Doc View SourceCreatePublicEndpointAsync(ProtocolType, Int32)
Create an endpoint that can be connected to by devices outside of the NAT.
Declaration
public override Task<Lease> CreatePublicEndpointAsync(ProtocolType protocol, int port)
Parameters
Type | Name | Description |
---|---|---|
ProtocolType | protocol | |
Int32 | port | The intenral port of the server. |
Returns
Type | Description |
---|---|
Task<Lease> | A task that represents the asynchronous operation. The task's result is a Lease that defines an endpoint that is connectable by devices not behind the NAT. |
Overrides
| Improve this Doc View SourceDeletePublicEndpointAsync(Lease)
Cancel the lease.
Declaration
public override Task DeletePublicEndpointAsync(Lease lease)
Parameters
Type | Name | Description |
---|---|---|
Lease | lease | The lease to break. |
Returns
Type | Description |
---|---|
Task | A task that represents the asynchronous operation. |
Overrides
Remarks
Tells that NAT that the public endpoint can be removed.
IsAvailableAsync()
Determines if the NAT is online.
Declaration
public override Task<bool> IsAvailableAsync()
Returns
Type | Description |
---|---|
Task<Boolean> | A task that represents the asynchronous operation. The task's result is true if the NAT is online and speaks the correct protocol; otherwise, false. |
Overrides
| Improve this Doc View SourceRenewPublicEndpointAsync(Lease)
Renew the lease.
Declaration
public override Task<Lease> RenewPublicEndpointAsync(Lease lease)
Parameters
Type | Name | Description |
---|---|---|
Lease | lease | The lease to renew. |
Returns
Type | Description |
---|---|
Task<Lease> | A task that represents the asynchronous operation. The task's result is a Lease that defines an endpoint that is connectable by devices not behind the NAT. |
Overrides
Remarks
The returned Lease may have different external address
and/or port than the original lease
.