WPILibC++  2020.3.2
Client/Server Functions

Functions

void nt::SetNetworkIdentity (StringRef name)
 Set the network identity of this node. More...
 
void nt::SetNetworkIdentity (NT_Inst inst, const Twine &name)
 Set the network identity of this node. More...
 
unsigned int nt::GetNetworkMode ()
 Get the current network mode. More...
 
unsigned int nt::GetNetworkMode (NT_Inst inst)
 Get the current network mode. More...
 
void nt::StartLocal (NT_Inst inst)
 Starts local-only operation. More...
 
void nt::StopLocal (NT_Inst inst)
 Stops local-only operation. More...
 
void nt::StartServer (StringRef persist_filename, const char *listen_address, unsigned int port)
 Starts a server using the specified filename, listening address, and port. More...
 
void nt::StartServer (NT_Inst inst, const Twine &persist_filename, const char *listen_address, unsigned int port)
 Starts a server using the specified filename, listening address, and port. More...
 
void nt::StopServer ()
 Stops the server if it is running.
 
void nt::StopServer (NT_Inst inst)
 Stops the server if it is running. More...
 
void nt::StartClient ()
 Starts a client. More...
 
void nt::StartClient (const char *server_name, unsigned int port)
 Starts a client using the specified server and port. More...
 
void nt::StartClient (ArrayRef< std::pair< StringRef, unsigned int >> servers)
 Starts a client using the specified (server, port) combinations. More...
 
void nt::StartClient (NT_Inst inst)
 Starts a client. More...
 
void nt::StartClient (NT_Inst inst, const char *server_name, unsigned int port)
 Starts a client using the specified server and port. More...
 
void nt::StartClient (NT_Inst inst, ArrayRef< std::pair< StringRef, unsigned int >> servers)
 Starts a client using the specified (server, port) combinations. More...
 
void nt::StartClientTeam (NT_Inst inst, unsigned int team, unsigned int port)
 Starts a client using commonly known robot addresses for the specified team. More...
 
void nt::StopClient ()
 Stops the client if it is running.
 
void nt::StopClient (NT_Inst inst)
 Stops the client if it is running. More...
 
void nt::SetServer (const char *server_name, unsigned int port)
 Sets server address and port for client (without restarting client). More...
 
void nt::SetServer (ArrayRef< std::pair< StringRef, unsigned int >> servers)
 Sets server addresses for client (without restarting client). More...
 
void nt::SetServer (NT_Inst inst, const char *server_name, unsigned int port)
 Sets server address and port for client (without restarting client). More...
 
void nt::SetServer (NT_Inst inst, ArrayRef< std::pair< StringRef, unsigned int >> servers)
 Sets server addresses for client (without restarting client). More...
 
void nt::SetServerTeam (NT_Inst inst, unsigned int team, unsigned int port)
 Sets server addresses and port for client (without restarting client). More...
 
void nt::StartDSClient (unsigned int port)
 Starts requesting server address from Driver Station. More...
 
void nt::StartDSClient (NT_Inst inst, unsigned int port)
 Starts requesting server address from Driver Station. More...
 
void nt::StopDSClient ()
 Stops requesting server address from Driver Station.
 
void nt::StopDSClient (NT_Inst inst)
 Stops requesting server address from Driver Station. More...
 
void nt::StopRpcServer ()
 Stops the RPC server if it is running.
 
void nt::SetUpdateRate (double interval)
 Set the periodic update rate. More...
 
void nt::SetUpdateRate (NT_Inst inst, double interval)
 Set the periodic update rate. More...
 
void nt::Flush ()
 Flush Entries. More...
 
void nt::Flush (NT_Inst inst)
 Flush Entries. More...
 
std::vector< ConnectionInfont::GetConnections ()
 Get information on the currently established network connections. More...
 
std::vector< ConnectionInfont::GetConnections (NT_Inst inst)
 Get information on the currently established network connections. More...
 
bool nt::IsConnected (NT_Inst inst)
 Return whether or not the instance is connected to another node. More...
 

Detailed Description

Function Documentation

◆ Flush() [1/2]

void nt::Flush ( )

Flush Entries.

Forces an immediate flush of all local entry changes to network. Normally this is done on a regularly scheduled interval (see SetUpdateRate()).

Note: flushes are rate limited to avoid excessive network traffic. If the time between calls is too short, the flush will occur after the minimum time elapses (rather than immediately).

◆ Flush() [2/2]

void nt::Flush ( NT_Inst  inst)

Flush Entries.

Forces an immediate flush of all local entry changes to network. Normally this is done on a regularly scheduled interval (see SetUpdateRate()).

Note: flushes are rate limited to avoid excessive network traffic. If the time between calls is too short, the flush will occur after the minimum time elapses (rather than immediately).

Parameters
instinstance handle

◆ GetConnections() [1/2]

std::vector<ConnectionInfo> nt::GetConnections ( )

Get information on the currently established network connections.

If operating as a client, this will return either zero or one values.

Returns
array of connection information

◆ GetConnections() [2/2]

std::vector<ConnectionInfo> nt::GetConnections ( NT_Inst  inst)

Get information on the currently established network connections.

If operating as a client, this will return either zero or one values.

Returns
array of connection information
Parameters
instinstance handle

◆ GetNetworkMode() [1/2]

unsigned int nt::GetNetworkMode ( )

Get the current network mode.

Returns
Bitmask of NT_NetworkMode.

◆ GetNetworkMode() [2/2]

unsigned int nt::GetNetworkMode ( NT_Inst  inst)

Get the current network mode.

Parameters
instinstance handle
Returns
Bitmask of NT_NetworkMode.

◆ IsConnected()

bool nt::IsConnected ( NT_Inst  inst)

Return whether or not the instance is connected to another node.

Parameters
instinstance handle
Returns
True if connected.

◆ SetNetworkIdentity() [1/2]

void nt::SetNetworkIdentity ( NT_Inst  inst,
const Twine name 
)

Set the network identity of this node.

This is the name used during the initial connection handshake, and is visible through ConnectionInfo on the remote node.

Parameters
nameidentity to advertise
instinstance handle

◆ SetNetworkIdentity() [2/2]

void nt::SetNetworkIdentity ( StringRef  name)

Set the network identity of this node.

This is the name used during the initial connection handshake, and is visible through ConnectionInfo on the remote node.

Parameters
nameidentity to advertise

◆ SetServer() [1/4]

void nt::SetServer ( ArrayRef< std::pair< StringRef, unsigned int >>  servers)

Sets server addresses for client (without restarting client).

The client will attempt to connect to each server in round robin fashion.

Parameters
serversarray of server name and port pairs

◆ SetServer() [2/4]

void nt::SetServer ( const char *  server_name,
unsigned int  port 
)

Sets server address and port for client (without restarting client).

Parameters
server_nameserver name (UTF-8 string, null terminated)
portport to communicate over

◆ SetServer() [3/4]

void nt::SetServer ( NT_Inst  inst,
ArrayRef< std::pair< StringRef, unsigned int >>  servers 
)

Sets server addresses for client (without restarting client).

The client will attempt to connect to each server in round robin fashion.

Parameters
serversarray of server name and port pairs
instinstance handle

◆ SetServer() [4/4]

void nt::SetServer ( NT_Inst  inst,
const char *  server_name,
unsigned int  port 
)

Sets server address and port for client (without restarting client).

Parameters
server_nameserver name (UTF-8 string, null terminated)
portport to communicate over
instinstance handle

◆ SetServerTeam()

void nt::SetServerTeam ( NT_Inst  inst,
unsigned int  team,
unsigned int  port 
)

Sets server addresses and port for client (without restarting client).

Connects using commonly known robot addresses for the specified team.

Parameters
instinstance handle
teamteam number
portport to communicate over

◆ SetUpdateRate() [1/2]

void nt::SetUpdateRate ( double  interval)

Set the periodic update rate.

Sets how frequently updates are sent to other nodes over the network.

Parameters
intervalupdate interval in seconds (range 0.01 to 1.0)

◆ SetUpdateRate() [2/2]

void nt::SetUpdateRate ( NT_Inst  inst,
double  interval 
)

Set the periodic update rate.

Sets how frequently updates are sent to other nodes over the network.

Parameters
intervalupdate interval in seconds (range 0.01 to 1.0)
instinstance handle

◆ StartClient() [1/6]

void nt::StartClient ( )

Starts a client.

Use SetServer to set the server name and port.

◆ StartClient() [2/6]

void nt::StartClient ( ArrayRef< std::pair< StringRef, unsigned int >>  servers)

Starts a client using the specified (server, port) combinations.

The client will attempt to connect to each server in round robin fashion.

Parameters
serversarray of server name and port pairs

◆ StartClient() [3/6]

void nt::StartClient ( const char *  server_name,
unsigned int  port 
)

Starts a client using the specified server and port.

Parameters
server_nameserver name (UTF-8 string, null terminated)
portport to communicate over

◆ StartClient() [4/6]

void nt::StartClient ( NT_Inst  inst)

Starts a client.

Use SetServer to set the server name and port.

Parameters
instinstance handle

◆ StartClient() [5/6]

void nt::StartClient ( NT_Inst  inst,
ArrayRef< std::pair< StringRef, unsigned int >>  servers 
)

Starts a client using the specified (server, port) combinations.

The client will attempt to connect to each server in round robin fashion.

Parameters
serversarray of server name and port pairs
instinstance handle

◆ StartClient() [6/6]

void nt::StartClient ( NT_Inst  inst,
const char *  server_name,
unsigned int  port 
)

Starts a client using the specified server and port.

Parameters
server_nameserver name (UTF-8 string, null terminated)
portport to communicate over
instinstance handle

◆ StartClientTeam()

void nt::StartClientTeam ( NT_Inst  inst,
unsigned int  team,
unsigned int  port 
)

Starts a client using commonly known robot addresses for the specified team.

Parameters
instinstance handle
teamteam number
portport to communicate over

◆ StartDSClient() [1/2]

void nt::StartDSClient ( NT_Inst  inst,
unsigned int  port 
)

Starts requesting server address from Driver Station.

This connects to the Driver Station running on localhost to obtain the server IP address.

Parameters
portserver port to use in combination with IP from DS
instinstance handle

◆ StartDSClient() [2/2]

void nt::StartDSClient ( unsigned int  port)

Starts requesting server address from Driver Station.

This connects to the Driver Station running on localhost to obtain the server IP address.

Parameters
portserver port to use in combination with IP from DS

◆ StartLocal()

void nt::StartLocal ( NT_Inst  inst)

Starts local-only operation.

Prevents calls to StartServer or StartClient from taking effect. Has no effect if StartServer or StartClient has already been called.

◆ StartServer() [1/2]

void nt::StartServer ( NT_Inst  inst,
const Twine persist_filename,
const char *  listen_address,
unsigned int  port 
)

Starts a server using the specified filename, listening address, and port.

Parameters
persist_filenamethe name of the persist file to use (UTF-8 string, null terminated)
listen_addressthe address to listen on, or null to listen on any address. (UTF-8 string, null terminated)
portport to communicate over.
instinstance handle

◆ StartServer() [2/2]

void nt::StartServer ( StringRef  persist_filename,
const char *  listen_address,
unsigned int  port 
)

Starts a server using the specified filename, listening address, and port.

Parameters
persist_filenamethe name of the persist file to use (UTF-8 string, null terminated)
listen_addressthe address to listen on, or null to listen on any address. (UTF-8 string, null terminated)
portport to communicate over.

◆ StopClient()

void nt::StopClient ( NT_Inst  inst)

Stops the client if it is running.

Parameters
instinstance handle

◆ StopDSClient()

void nt::StopDSClient ( NT_Inst  inst)

Stops requesting server address from Driver Station.

Parameters
instinstance handle

◆ StopLocal()

void nt::StopLocal ( NT_Inst  inst)

Stops local-only operation.

StartServer or StartClient can be called after this call to start a server or client.

◆ StopServer()

void nt::StopServer ( NT_Inst  inst)

Stops the server if it is running.

Parameters
instinstance handle