> For the complete documentation index, see [llms.txt](https://docs.optitrack.com/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.optitrack.com/v1.1/developer-tools/natnet-sdk/natnet-remote-requests-commands.md).

# NatNet: Remote Requests/Commands

## Remote Requests/Commands

***

\
The NatNet SDK features methods for sending remote commands and requests from a client application over to a connected server application. The SendMessageAndWait method within a NatNetClient object passes one of the NatNet commands each time it's called. NatNet commands are sent via the UDP connection; 1510 port by default. Once a NatNet server application (e.g. Motive) receives the remote command, corresponding actions will be performed.

For a sample use of NatNet commands, refer to the provided WinFormSample.

<br>

#### NatNetClient::SendMessageAndWait

```
ErrorCode	SendMessageAndWait( const char* szRequest,
				    void** ppServerResponse, 
					int* pResponseSize );
```

```
ErrorCode	SendMessageAndWait( const char* szRequest,
				    int tries, int timeout, 
				    void** ppServerResponse,
				    int* pResponseSize );
```

**Description**

Sends a NatNet command to the NatNet server and waits for a response.

**Input Parameters:**

* szRequest: NatNet command.
* tries: Number of attempts to send the command. Default: 10.
* timeout: Number of milliseconds to wait for a response from the server before the call times out. Default: 20.
* ppServerResponse: Application defined response.
* pResponseSize: Number of bytes in response

**Returns:**

ErrorCode, On success, it returns 0 or ErrorCode\_OK indicating that the remmote message have been successfully delivered.

#### Motive Supported NatNet Commands/Requests

| Command (string)           | Description                                               | Parameters   | Returns                |
| -------------------------- | --------------------------------------------------------- | ------------ | ---------------------- |
| UnitsToMillimeters         | Request current system’s units, in terms of millimeters   | none         | float                  |
| FrameRate                  | Request current system’s tracking framerate               | none         | float                  |
| StartRecording             | Start recording                                           | none         | none                   |
| StopRecording              | Stop recording                                            | none         | none                   |
| LiveMode                   | Switch to Live mode                                       | none         | none                   |
| EditMode                   | Switch to Edit mode                                       | none         | None                   |
| CurrentMode                | Request current mode                                      | none         | int                    |
| TimelinePlay               | Start take playback                                       | none         | none                   |
| TimelineStop               | Stop take playback                                        | none         | none                   |
| SetPlaybackTakeName        | Set playback take                                         | Take name    | None                   |
| SetRecordTakeName          | Set record take name                                      | Take name    | None                   |
| SetCurrentSession          | Set current session                                       | Session name | None                   |
| SetPlaybackStartFrame      | Set start frame                                           | Frame number | None                   |
| SetPlaybackStopFrame       | Set stop frame                                            | Frame number | None                   |
| SetPlaybackCurrentFrame    | Set current frame                                         | Frame number | None                   |
| CurrentTakeLength          | Request length of current take                            | None         | Number of frames (int) |
| AnalogSamplesPerMocapFrame | Request number of analog samples per motion capture frame | None         | int                    |

## Sample Use

***

\
Below is a sample use of the NatNet commands from the WinFormsSample application.

```
private void RecordButton_Click(object sender, EventArgs e)
{
	string command = "StartRecording";

	int nBytes = 0;
	byte[] response = new byte[10000];
	int rc = m_NatNet.SendMessageAndWait(command, 3, 100, out response, out nBytes);
	if (rc != 0)
	{
		OutputMessage(command + " not handled by server");
	}
	else
	{
		int opResult = System.BitConverter.ToInt32(response, 0);
		if (opResult == 0)
			OutputMessage(command + " handled and succeeded.");
		else
			OutputMessage(command + " handled but failed.");
	}
}
```


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://docs.optitrack.com/v1.1/developer-tools/natnet-sdk/natnet-remote-requests-commands.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
