zCm 0.1.0
Lightweight messaging toolkit
Loading...
Searching...
No Matches
Low-Level API

Core messaging, registry, socket, and context primitives. More...

Data Structures

struct  zcm_msg_value
 Decoded standardized scalar value extracted from a message. More...
struct  zcm_node_entry
 Node listing entry returned by zcm_node_list(). More...

Macros

#define ZCM_OK   0
 Success return code.
#define ZCM_ERR   (-1)
 Generic failure return code.
#define ZCM_NODE_REGISTER_EX_DUPLICATE   (-2)
 zcm_node_register_ex() failure code when a name is already owned by another process.

Typedefs

typedef struct zcm_context zcm_context_t
 Opaque process-wide context handle.
typedef struct zcm_broker zcm_broker_t
 Opaque broker handle.
typedef struct zcm_msg zcm_msg_t
 Opaque typed message container.
typedef struct zcm_msg_value zcm_msg_value_t
 Decoded standardized scalar value extracted from a message.
typedef struct zcm_node zcm_node_t
 Opaque broker-registry client handle.
typedef struct zcm_socket zcm_socket_t
 Opaque transport socket wrapper.
typedef struct zcm_node_entry zcm_node_entry_t
 Node listing entry returned by zcm_node_list().

Enumerations

enum  zcm_msg_item_type_t {
  ZCM_MSG_ITEM_CHAR = 1 , ZCM_MSG_ITEM_SHORT = 2 , ZCM_MSG_ITEM_INT = 3 , ZCM_MSG_ITEM_LONG = 4 ,
  ZCM_MSG_ITEM_FLOAT = 5 , ZCM_MSG_ITEM_DOUBLE = 6 , ZCM_MSG_ITEM_ARRAY = 7 , ZCM_MSG_ITEM_TEXT = 8 ,
  ZCM_MSG_ITEM_BYTES = 9
}
 Encoded item kind stored in a message payload. More...
enum  zcm_msg_array_type_t {
  ZCM_MSG_ARRAY_CHAR = 1 , ZCM_MSG_ARRAY_SHORT = 2 , ZCM_MSG_ARRAY_INT = 3 , ZCM_MSG_ARRAY_FLOAT = 4 ,
  ZCM_MSG_ARRAY_DOUBLE = 5
}
 Element type for array payload items. More...
enum  zcm_msg_status_t {
  ZCM_MSG_OK = 0 , ZCM_MSG_ERR = -1 , ZCM_MSG_ERR_TYPE = -2 , ZCM_MSG_ERR_RANGE = -3 ,
  ZCM_MSG_ERR_FORMAT = -4
}
 Status/error codes returned by zcm_msg APIs. More...
enum  zcm_msg_value_kind_t { ZCM_MSG_VALUE_TEXT = 1 , ZCM_MSG_VALUE_DOUBLE = 2 , ZCM_MSG_VALUE_FLOAT = 3 , ZCM_MSG_VALUE_INT = 4 }
 Canonical scalar kind used by the standardized value property. More...
enum  zcm_socket_type_t {
  ZCM_SOCK_REQ = 1 , ZCM_SOCK_REP = 2 , ZCM_SOCK_PUB = 3 , ZCM_SOCK_SUB = 4 ,
  ZCM_SOCK_PAIR = 5 , ZCM_SOCK_PUSH = 6 , ZCM_SOCK_PULL = 7
}
 Socket type abstraction mapped to ZeroMQ socket kinds. More...

Functions

zcm_context_tzcm_context_new (void)
 Create a new zCm context.
void zcm_context_free (zcm_context_t *ctx)
 Destroy a context created by zcm_context_new().
zcm_broker_tzcm_broker_start (zcm_context_t *ctx, const char *endpoint)
 Start a broker service bound to the provided endpoint.
void zcm_broker_stop (zcm_broker_t *broker)
 Stop and free a broker created by zcm_broker_start().
int zcm_broker_is_running (const zcm_broker_t *broker)
 Check whether a broker service loop is still running.
const char * zcm_version_string (void)
 Return the library version string.
void * zcm_context_zmq (zcm_context_t *ctx)
 Get the underlying ZeroMQ context pointer.
zcm_msg_tzcm_msg_new (void)
 Allocate a new empty message.
void zcm_msg_free (zcm_msg_t *msg)
 Free a message allocated by zcm_msg_new().
void zcm_msg_reset (zcm_msg_t *msg)
 Clear payload, type name, and read cursor of a message.
void zcm_msg_rewind (zcm_msg_t *msg)
 Reset only the payload read cursor to the beginning.
int zcm_msg_set_type (zcm_msg_t *msg, const char *type)
 Set application-level message type string.
const char * zcm_msg_get_type (const zcm_msg_t *msg)
 Get the message type string.
int zcm_msg_put_char (zcm_msg_t *msg, char value)
 Append a char item.
int zcm_msg_put_short (zcm_msg_t *msg, int16_t value)
 Append a 16-bit signed integer item.
int zcm_msg_put_int (zcm_msg_t *msg, int32_t value)
 Append a 32-bit signed integer item.
int zcm_msg_put_long (zcm_msg_t *msg, int64_t value)
 Append a 64-bit signed integer item.
int zcm_msg_put_float (zcm_msg_t *msg, float value)
 Append a float item.
int zcm_msg_put_double (zcm_msg_t *msg, double value)
 Append a double item.
int zcm_msg_put_text (zcm_msg_t *msg, const char *value)
 Append a UTF-8 or ASCII text item.
int zcm_msg_put_bytes (zcm_msg_t *msg, const void *data, uint32_t len)
 Append an opaque byte buffer item.
int zcm_msg_put_array (zcm_msg_t *msg, zcm_msg_array_type_t type, uint32_t elements, const void *data)
 Append an array item.
int zcm_msg_put_value_text (zcm_msg_t *msg, const char *value)
 Append the standardized scalar value as text.
int zcm_msg_put_value_double (zcm_msg_t *msg, double value)
 Append the standardized scalar value as double.
int zcm_msg_put_value_float (zcm_msg_t *msg, float value)
 Append the standardized scalar value as float.
int zcm_msg_put_value_int (zcm_msg_t *msg, int32_t value)
 Append the standardized scalar value as int.
int zcm_msg_get_char (zcm_msg_t *msg, char *value)
 Read the next char item.
int zcm_msg_get_short (zcm_msg_t *msg, int16_t *value)
 Read the next 16-bit signed integer item.
int zcm_msg_get_int (zcm_msg_t *msg, int32_t *value)
 Read the next 32-bit signed integer item.
int zcm_msg_get_long (zcm_msg_t *msg, int64_t *value)
 Read the next 64-bit signed integer item.
int zcm_msg_get_float (zcm_msg_t *msg, float *value)
 Read the next float item.
int zcm_msg_get_double (zcm_msg_t *msg, double *value)
 Read the next double item.
int zcm_msg_get_text (zcm_msg_t *msg, const char **value, uint32_t *len)
 Read the next text item.
int zcm_msg_get_bytes (zcm_msg_t *msg, const void **data, uint32_t *len)
 Read the next raw byte item.
int zcm_msg_get_array (zcm_msg_t *msg, zcm_msg_array_type_t *type, uint32_t *elements, const void **data)
 Read the next array item.
int zcm_msg_get_value (zcm_msg_t *msg, zcm_msg_value_t *out)
 Decode the standardized scalar value from the current read offset.
const void * zcm_msg_data (const zcm_msg_t *msg, size_t *len)
 Get raw payload bytes (without transport envelope).
size_t zcm_msg_remaining (const zcm_msg_t *msg)
 Get unread payload bytes remaining from current read cursor.
int zcm_msg_from_bytes (zcm_msg_t *msg, const void *data, size_t len)
 Load message state from serialized envelope bytes.
int zcm_msg_validate (const zcm_msg_t *msg)
 Validate encoded payload structure.
const char * zcm_msg_last_error (const zcm_msg_t *msg)
 Get the last decode/validation error text for a message.
zcm_node_tzcm_node_new (struct zcm_context *ctx, const char *broker_endpoint)
 Create a node helper bound to one broker endpoint.
void zcm_node_free (zcm_node_t *node)
 Destroy a node created by zcm_node_new().
int zcm_node_unregister (zcm_node_t *node, const char *name)
 Remove a previously registered name from the broker.
int zcm_node_register_ex (zcm_node_t *node, const char *name, const char *endpoint, const char *ctrl_endpoint, const char *host, int pid, const char *role, int pub_port, int push_port)
 Register a process with extended metadata.
int zcm_node_lookup (zcm_node_t *node, const char *name, char *out_endpoint, size_t out_size)
 Resolve a registered name to its endpoint.
int zcm_node_info (zcm_node_t *node, const char *name, char *out_endpoint, size_t out_ep_size, char *out_ctrl_endpoint, size_t out_ctrl_size, char *out_host, size_t out_host_size, int *out_pid)
 Fetch extended metadata for a registered name.
int zcm_node_list (zcm_node_t *node, zcm_node_entry_t **out_entries, size_t *out_count)
 List currently registered node entries.
void zcm_node_list_free (zcm_node_entry_t *entries, size_t count)
 Free list memory returned by zcm_node_list().
int zcm_node_report_metrics (zcm_node_t *node, const char *name, const char *role, int pub_port, int push_port, int pub_bytes, int sub_bytes, int push_bytes, int pull_bytes)
 Report runtime role/metric values for a registered name to the broker.
int zcm_node_handle_control_msg (zcm_msg_t *req, zcm_msg_t *reply, int *out_should_exit)
 Handle a standard ZCM_CMD management message.
zcm_socket_tzcm_socket_new (struct zcm_context *ctx, zcm_socket_type_t type)
 Create a transport socket wrapper.
void zcm_socket_free (zcm_socket_t *sock)
 Destroy a socket created by zcm_socket_new().
int zcm_socket_bind (zcm_socket_t *sock, const char *endpoint)
 Bind a socket to an endpoint.
int zcm_socket_connect (zcm_socket_t *sock, const char *endpoint)
 Connect a socket to an endpoint.
int zcm_socket_set_subscribe (zcm_socket_t *sock, const char *prefix, size_t len)
 Configure subscription prefix on a SUB socket.
int zcm_socket_send_msg (zcm_socket_t *sock, const zcm_msg_t *msg)
 Serialize and send a typed message.
int zcm_socket_recv_msg (zcm_socket_t *sock, zcm_msg_t *msg)
 Receive and decode a typed message.
int zcm_socket_send_bytes (zcm_socket_t *sock, const void *data, size_t len)
 Send raw bytes.
int zcm_socket_recv_bytes (zcm_socket_t *sock, void *buf, size_t buf_len, size_t *out_len)
 Receive raw bytes into a caller-provided buffer.
int zcm_socket_set_timeouts (zcm_socket_t *sock, int ms)
 Configure receive/send socket timeouts.

Detailed Description

This module is intended for code that needs direct control over transport sockets, typed payload encoding, and broker/node interactions.

Macro Definition Documentation

◆ ZCM_ERR

#define ZCM_ERR   (-1)

Definition at line 24 of file zcm.h.

◆ ZCM_NODE_REGISTER_EX_DUPLICATE

#define ZCM_NODE_REGISTER_EX_DUPLICATE   (-2)

Definition at line 53 of file zcm_node.h.

◆ ZCM_OK

#define ZCM_OK   0

Definition at line 22 of file zcm.h.

Typedef Documentation

◆ zcm_broker_t

typedef struct zcm_broker zcm_broker_t

Definition at line 29 of file zcm.h.

◆ zcm_context_t

typedef struct zcm_context zcm_context_t

Definition at line 27 of file zcm.h.

◆ zcm_msg_t

typedef struct zcm_msg zcm_msg_t

Definition at line 21 of file zcm_msg.h.

◆ zcm_node_t

typedef struct zcm_node zcm_node_t

Definition at line 24 of file zcm_node.h.

◆ zcm_socket_t

typedef struct zcm_socket zcm_socket_t

Definition at line 40 of file zcm_node.h.

Enumeration Type Documentation

◆ zcm_msg_array_type_t

Definition at line 41 of file zcm_msg.h.

◆ zcm_msg_item_type_t

Definition at line 26 of file zcm_msg.h.

◆ zcm_msg_status_t

Definition at line 52 of file zcm_msg.h.

◆ zcm_msg_value_kind_t

Definition at line 63 of file zcm_msg.h.

◆ zcm_socket_type_t

Definition at line 29 of file zcm_node.h.

Function Documentation

◆ zcm_broker_is_running()

int zcm_broker_is_running ( const zcm_broker_t * broker)
Parameters
brokerBroker handle.
Returns
1 when running, 0 when stopped or when broker is NULL.

◆ zcm_broker_start()

zcm_broker_t * zcm_broker_start ( zcm_context_t * ctx,
const char * endpoint )
Parameters
ctxValid zCm context.
endpointBroker bind endpoint, for example tcp://0.0.0.0:5555.
Returns
Broker handle on success, or NULL on failure.

◆ zcm_broker_stop()

void zcm_broker_stop ( zcm_broker_t * broker)
Parameters
brokerBroker handle to stop. NULL is allowed.

◆ zcm_context_free()

void zcm_context_free ( zcm_context_t * ctx)
Parameters
ctxContext to free. NULL is allowed.

◆ zcm_context_new()

zcm_context_t * zcm_context_new ( void )
Returns
Newly allocated context on success, or NULL on allocation/backend failure.

◆ zcm_context_zmq()

void * zcm_context_zmq ( zcm_context_t * ctx)

This is intended for internal integrations.

Parameters
ctxzCm context.
Returns
Native ZeroMQ context pointer, or NULL when ctx is NULL.

◆ zcm_msg_data()

const void * zcm_msg_data ( const zcm_msg_t * msg,
size_t * len )
Parameters
msgMessage to inspect.
lenOptional payload byte length output.
Returns
Pointer to internal payload buffer, or NULL when msg is NULL.

◆ zcm_msg_free()

void zcm_msg_free ( zcm_msg_t * msg)
Parameters
msgMessage to free. NULL is allowed.

◆ zcm_msg_from_bytes()

int zcm_msg_from_bytes ( zcm_msg_t * msg,
const void * data,
size_t len )
Parameters
msgDestination message to populate.
dataSerialized input bytes.
lenSize of data in bytes.
Returns
ZCM_MSG_OK on success, otherwise an error code.

◆ zcm_msg_get_array()

int zcm_msg_get_array ( zcm_msg_t * msg,
zcm_msg_array_type_t * type,
uint32_t * elements,
const void ** data )

Returned pointer references internal message storage.

Parameters
msgMessage to read from.
typeOutput array element type.
elementsOutput element count.
dataOutput pointer to contiguous array bytes.
Returns
ZCM_MSG_OK on success, otherwise an error code.

◆ zcm_msg_get_bytes()

int zcm_msg_get_bytes ( zcm_msg_t * msg,
const void ** data,
uint32_t * len )

Returned pointer references internal message storage.

Parameters
msgMessage to read from.
dataOutput pointer to the byte span.
lenOptional output byte count.
Returns
ZCM_MSG_OK on success, otherwise an error code.

◆ zcm_msg_get_char()

int zcm_msg_get_char ( zcm_msg_t * msg,
char * value )
Parameters
msgMessage to read from.
valueOutput storage for decoded value.
Returns
ZCM_MSG_OK on success, otherwise an error code.

◆ zcm_msg_get_double()

int zcm_msg_get_double ( zcm_msg_t * msg,
double * value )
Parameters
msgMessage to read from.
valueOutput storage for decoded value.
Returns
ZCM_MSG_OK on success, otherwise an error code.

◆ zcm_msg_get_float()

int zcm_msg_get_float ( zcm_msg_t * msg,
float * value )
Parameters
msgMessage to read from.
valueOutput storage for decoded value.
Returns
ZCM_MSG_OK on success, otherwise an error code.

◆ zcm_msg_get_int()

int zcm_msg_get_int ( zcm_msg_t * msg,
int32_t * value )
Parameters
msgMessage to read from.
valueOutput storage for decoded value.
Returns
ZCM_MSG_OK on success, otherwise an error code.

◆ zcm_msg_get_long()

int zcm_msg_get_long ( zcm_msg_t * msg,
int64_t * value )
Parameters
msgMessage to read from.
valueOutput storage for decoded value.
Returns
ZCM_MSG_OK on success, otherwise an error code.

◆ zcm_msg_get_short()

int zcm_msg_get_short ( zcm_msg_t * msg,
int16_t * value )
Parameters
msgMessage to read from.
valueOutput storage for decoded value.
Returns
ZCM_MSG_OK on success, otherwise an error code.

◆ zcm_msg_get_text()

int zcm_msg_get_text ( zcm_msg_t * msg,
const char ** value,
uint32_t * len )

Returned pointer references internal message storage.

Parameters
msgMessage to read from.
valueOutput pointer to text bytes (not null-terminated by contract).
lenOptional output string length in bytes.
Returns
ZCM_MSG_OK on success, otherwise an error code.

◆ zcm_msg_get_type()

const char * zcm_msg_get_type ( const zcm_msg_t * msg)
Parameters
msgMessage to inspect.
Returns
Pointer to internal type string, or NULL if msg is NULL.

◆ zcm_msg_get_value()

int zcm_msg_get_value ( zcm_msg_t * msg,
zcm_msg_value_t * out )

The function consumes the marker/kind/value triplet from the message stream.

Parameters
msgMessage to read from.
outOutput decoded value.
Returns
ZCM_MSG_OK on success, otherwise an error code.

◆ zcm_msg_last_error()

const char * zcm_msg_last_error ( const zcm_msg_t * msg)
Parameters
msgMessage to inspect.
Returns
Internal error string, or NULL when msg is NULL.

◆ zcm_msg_new()

zcm_msg_t * zcm_msg_new ( void )
Returns
New message handle, or NULL on allocation failure.

◆ zcm_msg_put_array()

int zcm_msg_put_array ( zcm_msg_t * msg,
zcm_msg_array_type_t type,
uint32_t elements,
const void * data )
Parameters
msgMessage to append to.
typeArray element type.
elementsElement count.
dataPointer to contiguous array memory. Must be non-NULL when elements > 0.
Returns
ZCM_MSG_OK on success, otherwise an error code.

◆ zcm_msg_put_bytes()

int zcm_msg_put_bytes ( zcm_msg_t * msg,
const void * data,
uint32_t len )
Parameters
msgMessage to append to.
dataByte pointer to encode. Can be NULL when len == 0.
lenNumber of bytes at data.
Returns
ZCM_MSG_OK on success, otherwise an error code.

◆ zcm_msg_put_char()

int zcm_msg_put_char ( zcm_msg_t * msg,
char value )
Parameters
msgMessage to append to.
valueValue to encode.
Returns
ZCM_MSG_OK on success, otherwise an error code.

◆ zcm_msg_put_double()

int zcm_msg_put_double ( zcm_msg_t * msg,
double value )
Parameters
msgMessage to append to.
valueValue to encode.
Returns
ZCM_MSG_OK on success, otherwise an error code.

◆ zcm_msg_put_float()

int zcm_msg_put_float ( zcm_msg_t * msg,
float value )
Parameters
msgMessage to append to.
valueValue to encode.
Returns
ZCM_MSG_OK on success, otherwise an error code.

◆ zcm_msg_put_int()

int zcm_msg_put_int ( zcm_msg_t * msg,
int32_t value )
Parameters
msgMessage to append to.
valueValue to encode.
Returns
ZCM_MSG_OK on success, otherwise an error code.

◆ zcm_msg_put_long()

int zcm_msg_put_long ( zcm_msg_t * msg,
int64_t value )
Parameters
msgMessage to append to.
valueValue to encode.
Returns
ZCM_MSG_OK on success, otherwise an error code.

◆ zcm_msg_put_short()

int zcm_msg_put_short ( zcm_msg_t * msg,
int16_t value )
Parameters
msgMessage to append to.
valueValue to encode.
Returns
ZCM_MSG_OK on success, otherwise an error code.

◆ zcm_msg_put_text()

int zcm_msg_put_text ( zcm_msg_t * msg,
const char * value )
Parameters
msgMessage to append to.
valueNull-terminated text pointer. NULL is treated as empty text.
Returns
ZCM_MSG_OK on success, otherwise an error code.

◆ zcm_msg_put_value_double()

int zcm_msg_put_value_double ( zcm_msg_t * msg,
double value )
Parameters
msgMessage to append to.
valueDouble value.
Returns
ZCM_MSG_OK on success, otherwise an error code.

◆ zcm_msg_put_value_float()

int zcm_msg_put_value_float ( zcm_msg_t * msg,
float value )
Parameters
msgMessage to append to.
valueFloat value.
Returns
ZCM_MSG_OK on success, otherwise an error code.

◆ zcm_msg_put_value_int()

int zcm_msg_put_value_int ( zcm_msg_t * msg,
int32_t value )
Parameters
msgMessage to append to.
valueInteger value.
Returns
ZCM_MSG_OK on success, otherwise an error code.

◆ zcm_msg_put_value_text()

int zcm_msg_put_value_text ( zcm_msg_t * msg,
const char * value )
Parameters
msgMessage to append to.
valueText value.
Returns
ZCM_MSG_OK on success, otherwise an error code.

◆ zcm_msg_remaining()

size_t zcm_msg_remaining ( const zcm_msg_t * msg)
Parameters
msgMessage to inspect.
Returns
Remaining unread payload bytes.

◆ zcm_msg_reset()

void zcm_msg_reset ( zcm_msg_t * msg)
Parameters
msgMessage to reset. NULL is allowed.

◆ zcm_msg_rewind()

void zcm_msg_rewind ( zcm_msg_t * msg)
Parameters
msgMessage to rewind. NULL is allowed.

◆ zcm_msg_set_type()

int zcm_msg_set_type ( zcm_msg_t * msg,
const char * type )
Parameters
msgMessage to modify.
typeNull-terminated type name.
Returns
ZCM_MSG_OK on success, otherwise an error code.

◆ zcm_msg_validate()

int zcm_msg_validate ( const zcm_msg_t * msg)
Parameters
msgMessage to validate.
Returns
ZCM_MSG_OK if the payload is structurally valid, otherwise an error code.

◆ zcm_node_free()

void zcm_node_free ( zcm_node_t * node)
Parameters
nodeNode handle to free. NULL is allowed.

◆ zcm_node_handle_control_msg()

int zcm_node_handle_control_msg ( zcm_msg_t * req,
zcm_msg_t * reply,
int * out_should_exit )

Supported commands:

  • PING -> reply REPLY(PONG,200)
  • DATA_METRICS -> reply REPLY(ROLE=NONE;PUB_PORT=-1;PUSH_PORT=-1;PUB_BYTES=-1;SUB_BYTES=-1;PUSH_BYTES=-1;PULL_BYTES=-1;SUB_TARGETS=-;SUB_TARGET_BYTES=-,200)
  • KILL -> reply REPLY(OK,200) and request process exit
  • SHUTDOWN -> reply REPLY(OK,200) and request process exit

For unsupported commands, the function writes ERROR(UNKNOWN_CMD,404).

Parameters
reqIncoming request message.
replyOutput reply message (reset by this function when handled).
out_should_exitSet to 1 when caller should terminate after sending reply.
Returns
1 when command was handled, 0 when request is not a ZCM_CMD control message, -1 on argument/internal errors.

◆ zcm_node_info()

int zcm_node_info ( zcm_node_t * node,
const char * name,
char * out_endpoint,
size_t out_ep_size,
char * out_ctrl_endpoint,
size_t out_ctrl_size,
char * out_host,
size_t out_host_size,
int * out_pid )

Any output pointer can be NULL to skip that field.

Parameters
nodeNode helper.
nameName to inspect.
out_endpointOutput buffer for data endpoint.
out_ep_sizeSize of out_endpoint.
out_ctrl_endpointOutput buffer for control endpoint.
out_ctrl_sizeSize of out_ctrl_endpoint.
out_hostOutput buffer for host name/address.
out_host_sizeSize of out_host.
out_pidOptional process ID output.
Returns
0 on success, -1 on failure.

◆ zcm_node_list()

int zcm_node_list ( zcm_node_t * node,
zcm_node_entry_t ** out_entries,
size_t * out_count )
Parameters
nodeNode helper.
out_entriesOutput array allocated by the library.
out_countOutput number of entries in out_entries.
Returns
0 on success, -1 on failure.

◆ zcm_node_list_free()

void zcm_node_list_free ( zcm_node_entry_t * entries,
size_t count )
Parameters
entriesEntry array pointer returned by zcm_node_list().
countNumber of entries in entries.

◆ zcm_node_lookup()

int zcm_node_lookup ( zcm_node_t * node,
const char * name,
char * out_endpoint,
size_t out_size )
Parameters
nodeNode helper.
nameName to resolve.
out_endpointOutput buffer receiving endpoint string.
out_sizeSize of out_endpoint in bytes.
Returns
0 on success, -1 on failure.

◆ zcm_node_new()

zcm_node_t * zcm_node_new ( struct zcm_context * ctx,
const char * broker_endpoint )
Parameters
ctxzCm context.
broker_endpointBroker endpoint string used for registry requests.
Returns
Node handle on success, or NULL on failure.

◆ zcm_node_register_ex()

int zcm_node_register_ex ( zcm_node_t * node,
const char * name,
const char * endpoint,
const char * ctrl_endpoint,
const char * host,
int pid,
const char * role,
int pub_port,
int push_port )
Parameters
nodeNode helper.
nameLogical process/service name.
endpointData endpoint.
ctrl_endpointControl endpoint used for management actions.
hostHostname or IP advertised by the process.
pidProcess ID.
roleNode role (PUB, SUB, PUSH, PULL, NONE, UNKNOWN, or combos like PUB+SUB).
pub_portPublished PUB port or -1.
push_portPublished PUSH port or -1.
Returns
0 on success, ZCM_NODE_REGISTER_EX_DUPLICATE on duplicate name, -1 on transport/internal failure.

◆ zcm_node_report_metrics()

int zcm_node_report_metrics ( zcm_node_t * node,
const char * name,
const char * role,
int pub_port,
int push_port,
int pub_bytes,
int sub_bytes,
int push_bytes,
int pull_bytes )

Any numeric value can be set to -1 when unknown/not applicable.

Parameters
nodeNode helper.
nameRegistered logical name.
roleRole string (for example PUB, SUB, PUB+SUB, EXTERNAL).
pub_portPublished PUB port or -1.
push_portPublished PUSH port or -1.
pub_bytesLast PUB payload byte size or -1.
sub_bytesLast SUB payload byte size or -1.
push_bytesLast PUSH payload byte size or -1.
pull_bytesLast PULL payload byte size or -1.
Returns
0 on success, -1 on failure.

◆ zcm_node_unregister()

int zcm_node_unregister ( zcm_node_t * node,
const char * name )
Parameters
nodeNode helper.
nameName to remove.
Returns
0 on success, -1 on failure.

◆ zcm_socket_bind()

int zcm_socket_bind ( zcm_socket_t * sock,
const char * endpoint )
Parameters
sockSocket wrapper.
endpointBind endpoint string.
Returns
0 on success, -1 on failure.

◆ zcm_socket_connect()

int zcm_socket_connect ( zcm_socket_t * sock,
const char * endpoint )
Parameters
sockSocket wrapper.
endpointRemote endpoint string.
Returns
0 on success, -1 on failure.

◆ zcm_socket_free()

void zcm_socket_free ( zcm_socket_t * sock)
Parameters
sockSocket wrapper to free. NULL is allowed.

◆ zcm_socket_new()

zcm_socket_t * zcm_socket_new ( struct zcm_context * ctx,
zcm_socket_type_t type )
Parameters
ctxzCm context.
typeDesired socket type.
Returns
Socket wrapper on success, or NULL on failure.

◆ zcm_socket_recv_bytes()

int zcm_socket_recv_bytes ( zcm_socket_t * sock,
void * buf,
size_t buf_len,
size_t * out_len )
Parameters
sockSocket wrapper.
bufDestination buffer.
buf_lenCapacity of buf in bytes.
out_lenOptional output with received byte count.
Returns
0 on success, -1 on failure.

◆ zcm_socket_recv_msg()

int zcm_socket_recv_msg ( zcm_socket_t * sock,
zcm_msg_t * msg )
Parameters
sockSocket wrapper.
msgDestination message object.
Returns
0 on success, -1 on transport/decode error.

◆ zcm_socket_send_bytes()

int zcm_socket_send_bytes ( zcm_socket_t * sock,
const void * data,
size_t len )
Parameters
sockSocket wrapper.
dataByte buffer to send. Can be NULL when len == 0.
lenNumber of bytes to send.
Returns
0 on success, -1 on failure.

◆ zcm_socket_send_msg()

int zcm_socket_send_msg ( zcm_socket_t * sock,
const zcm_msg_t * msg )
Parameters
sockSocket wrapper.
msgMessage to send.
Returns
0 on success, -1 on failure.

◆ zcm_socket_set_subscribe()

int zcm_socket_set_subscribe ( zcm_socket_t * sock,
const char * prefix,
size_t len )
Parameters
sockSocket wrapper.
prefixPrefix bytes. Can be empty for all topics.
lenPrefix size in bytes.
Returns
0 on success, -1 on failure.

◆ zcm_socket_set_timeouts()

int zcm_socket_set_timeouts ( zcm_socket_t * sock,
int ms )
Parameters
sockSocket wrapper.
msTimeout in milliseconds.
Returns
0 on success, -1 on failure.

◆ zcm_version_string()

const char * zcm_version_string ( void )
Returns
Null-terminated version string.