Show / Hide Table of Contents

Class Client

Communicates with a NAT that speaks the Port Mapping Protocol.

Inheritance
Object
NatClient
Client
Inherited Members
NatClient.RequestPort
NatClient.InitialTimeout
NatClient.MaxRetries
NatClient.LocalEndPoint
NatClient.RemoteEndPoint
NatClient.UnavailableReason
NatClient.SendAndReceiveAsync(NatMessage)
NatClient.SendAndReceiveAsync(Byte[])
Object.ToString()
Object.Equals(Object)
Object.Equals(Object, Object)
Object.ReferenceEquals(Object, Object)
Object.GetHashCode()
Object.GetType()
Object.MemberwiseClone()
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 Source

Client(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 Source

ProtocolVersion

The version of the NAT-PMP.

Declaration
public const int ProtocolVersion = 0
Field Value
Type Description
Int32

Methods

| Improve this Doc View Source

CreatePublicEndpointAsync(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

Either Tcp or Udp.

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
NatClient.CreatePublicEndpointAsync(ProtocolType, Int32)
| Improve this Doc View Source

DeletePublicEndpointAsync(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
NatClient.DeletePublicEndpointAsync(Lease)
Remarks

Tells that NAT that the public endpoint can be removed.

| Improve this Doc View Source

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
NatClient.IsAvailableAsync()
| Improve this Doc View Source

RenewPublicEndpointAsync(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
NatClient.RenewPublicEndpointAsync(Lease)
Remarks

The returned Lease may have different external address and/or port than the original lease.

See Also

RFC 6886 - NAT Port Mapping Protocol
RFC 6887 - NAT Port Control Protocol
  • Improve this Doc
  • View Source
Back to top Generated by DocFX