Connection⚓︎
Before you can communicate using a JMP connection, you first need to establish the connection. To do this, you need to define connection settings using the 'Connection Properties' object.
The 'Connection Properties' object allows you to define a connection's IP Address, Port number, Login Credentials, and if it should reconnect after the conection is lost. Settings you don't enter for the connection properties will use default values. You always need to provide an IP Address, but port 9220 is the default port, and 'jnior, jnior' (Admin Role) are the default login credentials. The connection is set to reconnect by default as well.
Connection Properties⚓︎
Version 26.0.0 - May 19, 2026
The Connection Properties structure is used to hold connection options. This structure is created by the user program and passed to the Create Connection method.
/**
* @param ip_address ip address of the target jnior
* @param port jmp protocol port. 9220 by default
* @param username The username to use for the initial authentication.
The default "jnior" will be used if one is
not provided.
* @param password The username to use for the initial authentication.
The default "jnior" will be used if one is
not provided.
* @param reconnect this connection will try to reconnect if
the connection is lost. This, by default, is true
* @param timeout_sec timeout in seconds. 5 seconds by default
*/
JMPLIB_EXPORT struct connection_properties {
const std::string ip_address;
const int port = 9220;
const int timeout_sec = 5;
bool reconnect = true;
std::string username = "jnior";
std::string password = "jnior";
};
Here is an example of how to define values for the Connection Properties object:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 | |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 | |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 | |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 | |
Create Connection⚓︎
Version 26.0.0 - May 19, 2026
Uses the previously mentioned Connection Properties. The JMP Connection Connect method is not directly callable and therefore doesn't have any returned status codes.
Waiting for the Connection⚓︎
Version 26.0.0 - May 19, 2026
After creating the connection, you can wait for the connection to either connect, or timeout. The Wait For Connection function call will return the status of the connection at the time of the return.
This call returns the moment the status is changed to CONNECTED or CONNECTION FAILED. This
Possible Status Returns:
- INVALID_UUID: If a JMP Connection is not found for the given UUID
sequenceDiagram
autonumber
Application->>connection_monitor_object: Wait for connection
Note right of Application: Application thread blocks until the<br>connection is made/fails or the timeout expires
loop
connection_monitor_object->>connection_monitor_object: 2 second timeout
end
JmpConnection-->>connection_monitor_object: Connected / Connection Failed
Note right of Application: returns the status of the connection
connection_monitor_object->>Application: <Connection Status>
Note right of Application: Application continues...
This is how you would call it in code...
1 2 | |
1 2 3 4 5 6 7 | |
1 2 3 | |
1 2 3 | |
Connection Status⚓︎
Version 26.0.0 - May 19, 2026
You can manually check the status of the connection by using the Get Connection Status function.
Possible Status Returns:
- INVALID_UUID: If a JMP Connection is not found for the given UUID
1 2 | |
1 2 | |
1 2 | |
1 2 | |
Connection Status Description⚓︎
Version 26.0.0 - May 19, 2026
Alternatively, you can get a string description for state of the connection by using the Get Connection Status Description function.
Possible Status Returns:
- INVALID_UUID: If a JMP Connection is not found for the given UUID
1 2 3 4 | |
1 2 | |
1 2 | |
1 2 | |
Disconnect⚓︎
Version 26.0.0 - May 19, 2026
When you are done with a connection, you can us the Disconnect function to end it. To reestablish a connection to the unit, you will need to create a new connection.
Possible Status Returns:
- INVALID_UUID: If a JMP Connection is not found for the given UUID
- DISCONNECTED: Returned no matter what the current state of the socket is.
1 | |
1 2 | |
1 2 | |
1 2 | |
Connection Callback⚓︎
Version 26.0.0 - May 19, 2026
Optionally, a callback can be assigned that will be alerted when ever there is a change to any of the connections. In order for the collback to be effective, it must be defined before any connections are defined. To define the call back we can do the following...
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 | |
1 2 3 4 5 6 7 8 9 10 11 | |
1 2 3 4 5 6 7 8 9 10 11 12 | |
1 2 3 4 5 6 7 8 9 10 | |
The callback is alerted any time taht the connection status changes. The callbacks you should see are NOT_CONNECTED, CONNECTING, CONNECTED, DISCONNECTING, and DISCONNECTED. You might also see CONNECTION_FAILED if your connection fails.
Connection STATUS codes⚓︎
Please go to the Connection Status Codes section.