# proc_add_peer

- **Language:** C
- **Kind:** function
- **Source:** https://github.com/tmux/tmux/blob/e476c1230b958df0cb12977517d24b3dc931375b/proc.c#L313
- **Page:** https://libtmux.org/en/tmux/latest/reference/c-function-proc_add_peer/

```c
struct tmuxpeer * proc_add_peer(struct tmuxproc *tp, int fd, void(*dispatchcb)(struct imsg *, void *), void *arg)
```

## Parameters

- `tp` (`struct tmuxproc *`)
- `fd` (`int`)
- `dispatchcb` (`void(*)(struct imsg *, void *)`)
- `arg` (`void *`)

## Paths through the source

Arrows name source relationships, not a runtime execution order.

### Start the server and create a client

[`server_start`](/en/tmux/latest/reference/c-function-server_start/) — calls → [`server_client_create`](/en/tmux/latest/reference/c-function-server_client_create/) — calls → [`proc_add_peer`](/en/tmux/latest/reference/c-function-proc_add_peer/)

## Called by

- [`client_main`](/en/tmux/latest/reference/c-function-client_main/) (function) [Call site](https://github.com/tmux/tmux/blob/e476c1230b958df0cb12977517d24b3dc931375b/client.c#L301)
- [`server_client_create`](/en/tmux/latest/reference/c-function-server_client_create/) (function) [Call site](https://github.com/tmux/tmux/blob/e476c1230b958df0cb12977517d24b3dc931375b/server-client.c#L295)

## Calls

- [`fatal`](/en/tmux/latest/reference/c-function-fatal/) (function) [Call site](https://github.com/tmux/tmux/blob/e476c1230b958df0cb12977517d24b3dc931375b/proc.c#L326)
- [`getpeereid`](/en/tmux/latest/reference/c-function-getpeereid/) (function) [Call site](https://github.com/tmux/tmux/blob/e476c1230b958df0cb12977517d24b3dc931375b/proc.c#L330)
- [`log_debug`](/en/tmux/latest/reference/c-function-log_debug/) (function) [Call site](https://github.com/tmux/tmux/blob/e476c1230b958df0cb12977517d24b3dc931375b/proc.c#L333)
- [`proc_update_event`](/en/tmux/latest/reference/c-function-proc-c-proc_update_event/) (function) [Call site](https://github.com/tmux/tmux/blob/e476c1230b958df0cb12977517d24b3dc931375b/proc.c#L336)
- [`xcalloc`](/en/tmux/latest/reference/c-function-xcalloc/) (function) [Call site](https://github.com/tmux/tmux/blob/e476c1230b958df0cb12977517d24b3dc931375b/proc.c#L319)

## Other function references

- [`proc_event_cb`](/en/tmux/latest/reference/c-function-proc-c-proc_event_cb/) (function)

## Referenced declarations

- [`tmuxpeer.arg`](/en/tmux/latest/reference/c-struct-tmuxpeer-arg/) (attribute)
- [`tmuxpeer.dispatchcb`](/en/tmux/latest/reference/c-struct-tmuxpeer-dispatchcb/) (attribute)
- [`tmuxpeer.entry`](/en/tmux/latest/reference/c-struct-tmuxpeer-entry/) (attribute)
- [`tmuxpeer.event`](/en/tmux/latest/reference/c-struct-tmuxpeer-event/) (attribute)
- [`tmuxpeer.ibuf`](/en/tmux/latest/reference/c-struct-tmuxpeer-ibuf/) (attribute)
- [`tmuxpeer.parent`](/en/tmux/latest/reference/c-struct-tmuxpeer-parent/) (attribute)
- [`tmuxproc.peers`](/en/tmux/latest/reference/c-struct-tmuxproc-peers/) (attribute)
- [`tmuxpeer`](/en/tmux/latest/reference/c-struct-tmuxpeer/) (struct)
- [`tmuxproc`](/en/tmux/latest/reference/c-struct-tmuxproc/) (struct)
- [`tmuxpeer.uid`](/en/tmux/latest/reference/c-struct-tmuxpeer-uid/) (attribute)
