Show / Hide Table of Contents

Class NatClient

Communicates with a NAT device.

Inheritance
Object
NatClient
Client
Client
Inherited Members
Object.ToString()
Object.Equals(Object)
Object.Equals(Object, Object)
Object.ReferenceEquals(Object, Object)
Object.GetHashCode()
Object.GetType()
Object.MemberwiseClone()
Namespace: Makaretu.Nat
Assembly: Makaretu.Nat.dll
Syntax
public abstract class NatClient
Remarks

An abstract class that allows communication with a NAT device.

Constructors

| Improve this Doc View Source

NatClient(IPAddress, Int32)

Creates a new instance of the NatClient class with the specified IP Address of the NAT.

Declaration
public NatClient(IPAddress address, int port = 5351)
Parameters
Type Name Description
IPAddress address

The IP address of the NAT server.

Int32 port

The port of the NAT server.

Fields

| Improve this Doc View Source

RequestPort

The NAT port that receives requests.

Declaration
public const int RequestPort = 5351
Field Value
Type Description
Int32

Properties

| Improve this Doc View Source

InitialTimeout

The time to wait for a response from NAT.

Declaration
public TimeSpan InitialTimeout { get; set; }
Property Value
Type Description
TimeSpan

Defaults to 250ms.

| Improve this Doc View Source

LocalEndPoint

The local endpoint.

Declaration
public IPEndPoint LocalEndPoint { get; }
Property Value
Type Description
IPEndPoint

An IPEndPoint.

| Improve this Doc View Source

MaxRetries

Number of times to retry sending request.

Declaration
public int MaxRetries { get; set; }
Property Value
Type Description
Int32

Defaults to 4.

| Improve this Doc View Source

RemoteEndPoint

The remote endpoint.

Declaration
public IPEndPoint RemoteEndPoint { get; }
Property Value
Type Description
IPEndPoint

An IPEndPoint.

| Improve this Doc View Source

UnavailableReason

The reason why the NAT is not availble.

Declaration
public string UnavailableReason { get; protected set; }
Property Value
Type Description
String

"" if the NAT is available, or a reason why it is not available. null when IsAvailableAsync() has not been called,

Remarks

The property is only valid, after the IsAvailableAsync() method is called.

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 abstract 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.

| Improve this Doc View Source

DeletePublicEndpointAsync(Lease)

Cancel the lease.

Declaration
public abstract 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.

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 abstract 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.

| Improve this Doc View Source

RenewPublicEndpointAsync(Lease)

Renew the lease.

Declaration
public abstract 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.

Remarks

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

| Improve this Doc View Source

SendAndReceiveAsync(NatMessage)

TODO

Declaration
public Task<byte[]> SendAndReceiveAsync(NatMessage request)
Parameters
Type Name Description
NatMessage request
Returns
Type Description
Task<Byte[]>
| Improve this Doc View Source

SendAndReceiveAsync(Byte[])

TODO

Declaration
public Task<byte[]> SendAndReceiveAsync(byte[] request)
Parameters
Type Name Description
Byte[] request
Returns
Type Description
Task<Byte[]>
  • Improve this Doc
  • View Source
Back to top Generated by DocFX