# NatPunchthroughClient Class Reference
[NatPunchthrough]

Client code for NATPunchthrough. More...

`#include <NatPunchthroughClient.h>`

Inheritance diagram for NatPunchthroughClient:

List of all members.

## Public Member Functions
bool | OpenNAT (RakNetGUID destination, SystemAddress facilitator)
| Punchthrough a NAT. Doesn't connect, just tries to setup the routing table.
PunchthroughConfiguration * | GetPunchthroughConfiguration (void)
void | SetDebugInterface (NatPunchthroughDebugInterface *i)
unsigned short | GetUPNPExternalPort (void) const
unsigned short | GetUPNPInternalPort (void) const
RakNet::RakString | GetUPNPInternalAddress (void) const
virtual void | Update (void)
| Update is called every time a packet is checked for .
virtual PluginReceiveResult | OnReceive (Packet *packet)
virtual void | OnNewConnection (SystemAddress systemAddress, RakNetGUID rakNetGUID, bool isIncoming)
virtual void | OnClosedConnection (SystemAddress systemAddress, RakNetGUID rakNetGUID, PI2_LostConnectionReason lostConnectionReason)
virtual void | OnAttach (void)
virtual void | OnDetach (void)
virtual void | OnRakPeerShutdown (void)
| Called when RakPeer is shutdown.

## Detailed Description

Client code for NATPunchthrough.

Maintain connection to NatPunchthroughServer to process incoming connection attempts through NatPunchthroughClient
Client will send datagrams to port to estimate next port
Will simultaneously connect with another client once ports are estimated.

See also:
  NatTypeDetectionClient See also http://www.jenkinssoftware.com/raknet/manual/natpunchthrough.html

## Member Function Documentation

PunchthroughConfiguration* NatPunchthroughClient::GetPunchthroughConfiguration | ( | void |  | ) |

Modify the system configuration if desired Don't modify the variables in the structure while punchthrough is in progress

unsigned short NatPunchthroughClient::GetUPNPExternalPort | ( | void |  | ) | const

Returns the port on the router that incoming messages will be sent to UPNP needs to know this (See UPNP project)

Precondition:
  Must have connected to the facilitator first

Returns:
  Port that incoming messages will be sent to, from other clients. This probably won't be the same port RakNet was started on.

RakNet::RakString NatPunchthroughClient::GetUPNPInternalAddress | ( | void |  | ) | const

Returns our locally bound system address Equivalent to calling rakPeer->GetInternalID(UNASSIGNED_SYSTEM_ADDRESS).ToString(false);

Returns:
  Internal address that UPNP should forward messages to

unsigned short NatPunchthroughClient::GetUPNPInternalPort | ( | void |  | ) | const

Returns our internal port that RakNet was started on Equivalent to calling rakPeer->GetInternalID(UNASSIGNED_SYSTEM_ADDRESS).port

Returns:
  Port that incoming messages will arrive on, on our actual system.

virtual void NatPunchthroughClient::OnAttach | ( | void |  | ) | `[virtual]`

Called when the interface is attached

Parameters:

  `[in]` | peer | the instance of RakPeer that is calling Receive

Reimplemented from PluginInterface2.

virtual void NatPunchthroughClient::OnClosedConnection | ( | SystemAddress | systemAddress,
|  | RakNetGUID | rakNetGUID,
|  | PI2_LostConnectionReason | lostConnectionReason |
| ) |  |  | `[virtual]`

Called when a connection is dropped because the user called RakPeer::CloseConnection() for a particular system

Parameters:

  `[in]` | systemAddress | The system whose connection was closed
  `[in]` | rakNetGuid | The guid of the specified system
  `[in]` | lostConnectionReason | How the connection was closed: manually, connection lost, or notification of disconnection

Reimplemented from PluginInterface2.

virtual void NatPunchthroughClient::OnDetach | ( | void |  | ) | `[virtual]`

Called when the interface is detached

Parameters:

  `[in]` | peer | the instance of RakPeer that is calling Receive

Reimplemented from PluginInterface2.

virtual void NatPunchthroughClient::OnNewConnection | ( | SystemAddress | systemAddress,
|  | RakNetGUID | rakNetGUID,
|  | bool | isIncoming |
| ) |  |  | `[virtual]`

Called when we got a new connection

Parameters:

  `[in]` | systemAddress | Address of the new connection
  `[in]` | rakNetGuid | The guid of the specified system
  `[in]` | isIncoming | If true, this is ID_NEW_INCOMING_CONNECTION, or the equivalent

Reimplemented from PluginInterface2.

virtual PluginReceiveResult NatPunchthroughClient::OnReceive | ( | Packet * | packet | ) | `[virtual]`

OnReceive is called for every packet.

Parameters:

  `[in]` | packet | the packet that is being returned to the user

Returns:
  True to allow the game and other plugins to get this message, false to absorb it

Reimplemented from PluginInterface2.

void NatPunchthroughClient::SetDebugInterface | ( | NatPunchthroughDebugInterface * | i | ) |

Sets a callback to be called with debug messages

Parameters:

  `[in]` | i | Pointer to an interface. The pointer is stored, so don't delete it while in progress. Pass 0 to clear.

The documentation for this class was generated from the following file:

- d:/RakNet-3.x/Source/NatPunchthroughClient.h