Class NatClient
Communicates with a NAT device.
Inherited Members
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 SourceNatClient(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 SourceRequestPort
The NAT port that receives requests.
Declaration
public const int RequestPort = 5351
Field Value
Type | Description |
---|---|
Int32 |
Properties
| Improve this Doc View SourceInitialTimeout
The time to wait for a response from NAT.
Declaration
public TimeSpan InitialTimeout { get; set; }
Property Value
Type | Description |
---|---|
TimeSpan | Defaults to 250ms. |
LocalEndPoint
The local endpoint.
Declaration
public IPEndPoint LocalEndPoint { get; }
Property Value
Type | Description |
---|---|
IPEndPoint | An IPEndPoint. |
MaxRetries
Number of times to retry sending request.
Declaration
public int MaxRetries { get; set; }
Property Value
Type | Description |
---|---|
Int32 | Defaults to 4. |
RemoteEndPoint
The remote endpoint.
Declaration
public IPEndPoint RemoteEndPoint { get; }
Property Value
Type | Description |
---|---|
IPEndPoint | An IPEndPoint. |
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 SourceCreatePublicEndpointAsync(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 | |
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. |
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.
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. |
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
.
SendAndReceiveAsync(NatMessage)
TODO
Declaration
public Task<byte[]> SendAndReceiveAsync(NatMessage request)
Parameters
Type | Name | Description |
---|---|---|
NatMessage | request |
Returns
Type | Description |
---|---|
Task<Byte[]> |
SendAndReceiveAsync(Byte[])
TODO
Declaration
public Task<byte[]> SendAndReceiveAsync(byte[] request)
Parameters
Type | Name | Description |
---|---|---|
Byte[] | request |
Returns
Type | Description |
---|---|
Task<Byte[]> |