Remote Access

The NxLib can start a server to allow remote access from other processes. This is useful for debugging with NxTreeEdit and for applications that are split across several processes.

Opening a Port for Remote Access

Open a port for remote access using the C functions nxLibOpenTcpPort and nxLibCloseTcpPort or their equivalent in the language wrappers.

You can specify the port number you want to use. When you specify port 0, the NxLib will choose a free port from the range 24000–25000.

// Open the port for remote access.
int openedPort = 0;
nxLibOpenTcpPort(0, &openedPort);

// Let other processes connect...

// Close the port again.
nxLibCloseTcpPort();

Connecting to a Remote NxLib

To connect to the opened port, your program can use the NxLibRemote library instead of the normal NxLib. It provides the same C API, but all tree operations are forwarded to a remote NxLib instance. For managing the connections, this library provides the additional C functions nxLibConnect and nxLibDisconnect.

Before connecting, another process has to initialize an instance of the NxLib and open the remote connection port as described above.

// Connect to an NxLib instance on the local system.
nxLibConnect("127.0.0.1", 24000);

// Use the remote NxLib with the normal API...

// Disconnect from the remote NxLib.
nxLibDisconnect();