---
name: "cpg_join"
section: "3"
platform: "linux"
package: "libcpg-dev"
version: "3.1.9-2+deb13u1"
release: "Debian 13 (Trixie)"
platforms: ["linux"]
url: "https://new.carta.tech/cpg_join"
---

# cpg\_join(3)

Joins one or more groups in the CPG library

## NAME

cpg\_join - Joins one or more groups in the CPG library

## SYNOPSIS

**#include \<corosync/cpg.h\>**

**int cpg\_join(cpg\_handle\_t** *handle***, struct cpg\_name \****group***);**

## DESCRIPTION

The **cpg\_join** function is used to join one group.  When a group is joined, the **[cpg\_mcast\_joined(3)](/cpg_mcast_joined/3.md)** is called internally to multicast to the groups joined in the argument *handle.* The process will also get notifications of other processes joining and leaving the group. Messages that are sent to any of the groups joined to the parameter *handle* will be delivered by **[cpg\_dispatch(3)](/cpg_dispatch/3.md).**

This function may be only be called once for each handle. When a group has been joined the process will start to receive callbacks relating to messages sent from members of the group or notifications of processes joining or leaving the group.

Note that more than one process on each node can join a CPG group and each will receive its own copy of any messages sent using *cpg\_mcast\_joined()* and its own confchg callback.

The argument *group* is used to specify the group to join.

The *groups* argument is of the type struct cpg\_name which is defined by the structure:

-

  ```
  struct cpg_name {
          int length;
          char value[128];
  };
  ```

-

  ## RETURN VALUE

This call returns the CS\_OK value if successful, CS\_ERR\_INVALID\_PARAM if the handle is already joined to a group.

## ERRORS

Not all errors are documented.

## SEE ALSO

[**cpg\_overview**(3)](/cpg_overview/3.md), [**cpg\_initialize**(3)](/cpg_initialize/3.md), [**cpg\_finalize**(3)](/cpg_finalize/3.md), [**cpg\_fd\_get**(3)](/cpg_fd_get/3.md), [**cpg\_dispatch**(3)](/cpg_dispatch/3.md), [**cpg\_join**(3)](/cpg_join/3.md), [**cpg\_leave**(3)](/cpg_leave/3.md), [**cpg\_mcast\_joined**(3)](/cpg_mcast_joined/3.md), [**cpg\_membership\_get**(3)](/cpg_membership_get/3.md) [**cpg\_zcb\_alloc**(3)](/cpg_zcb_alloc/3.md) [**cpg\_zcb\_free**(3)](/cpg_zcb_free/3.md) [**cpg\_zcb\_mcast\_joined**(3)](/cpg_zcb_mcast_joined/3.md) [**cpg\_context\_get**(3)](/cpg_context_get/3.md) [**cpg\_context\_set**(3)](/cpg_context_set/3.md) [**cpg\_local\_get**(3)](/cpg_local_get/3.md)

**CS\_ERR\_TRY\_AGAIN** Resource temporarily unavailable

**CS\_ERR\_INVALID\_PARAM** Invalid argument

**CS\_ERR\_ACCESS** Permission denied

**CS\_ERR\_LIBRARY** The connection failed

**CS\_ERR\_INTERRUPT** System call interrupted by a signal

**CS\_ERR\_NOT\_SUPPORTED** The requested protocol/functionality not supported

**CS\_ERR\_MESSAGE\_ERROR** Incorrect auth message received

**CS\_ERR\_NO\_MEMORY** Not enough memory to complete the requested task
