---
name: "wl_client"
section: "3"
platform: "linux"
package: "wayland-docs"
version: "1.26.0-1"
release: "Arch Linux 2026-11-01"
platforms: ["linux"]
url: "https://new.carta.tech/wl_client"
---

# wl\_client(3)

## NAME

wl\_client

## SYNOPSIS

### Public Member Functions

void **wl\_client\_flush** (struct **wl\_client** \*client)\
 struct **wl\_display** \* **wl\_client\_get\_display** (struct **wl\_client** \*client)\
 void **wl\_client\_get\_credentials** (const struct **wl\_client** \*client, pid\_t \***pid**, uid\_t \***uid**, gid\_t \***gid**)\
 int **wl\_client\_get\_fd** (struct **wl\_client** \*client)\
 struct **wl\_resource** \* **wl\_client\_get\_object** (struct **wl\_client** \*client, uint32\_t id)\
 void **wl\_client\_post\_implementation\_error** (struct **wl\_client** \*client, char const \*msg,...)\
 void **wl\_client\_add\_destroy\_listener** (struct **wl\_client** \*client, struct **wl\_listener** \*listener)\
 void **wl\_client\_add\_destroy\_late\_listener** (struct **wl\_client** \*client, struct **wl\_listener** \*listener)\
 struct **wl\_list** \* **wl\_client\_get\_link** (struct **wl\_client** \*client)\
 struct **wl\_client** \* **wl\_client\_from\_link** (struct **wl\_list** \***link**)\
 void **wl\_client\_add\_resource\_created\_listener** (struct **wl\_client** \*client, struct **wl\_listener** \*listener)\
 void **wl\_client\_for\_each\_resource** (struct **wl\_client** \*client, **wl\_client\_for\_each\_resource\_iterator\_func\_t** iterator, void \*user\_data)\
 void **wl\_client\_set\_max\_buffer\_size** (struct **wl\_client** \*client, size\_t max\_buffer\_size)\

### Data Fields

struct wl\_connection \* **connection**\
 struct **wl\_event\_source** \* **source**\
 struct **wl\_display** \* **display**\
 struct **wl\_resource** \* **display\_resource**\
 struct **wl\_list** **link**\
 struct wl\_map **objects**\
 struct wl\_priv\_signal **destroy\_signal**\
 struct wl\_priv\_signal **destroy\_late\_signal**\
 pid\_t **pid**\
 uid\_t **uid**\
 gid\_t **gid**\
 bool **error**\
 struct wl\_priv\_signal **resource\_created\_signal**\
 void \* **data**\
 **wl\_user\_data\_destroy\_func\_t** **data\_dtor**\

## Member Function Documentation

### void wl\_client\_add\_destroy\_late\_listener (struct wl\_client \* client, struct wl\_listener \* listener)

Add a listener to be called at the end of **wl\_client** destruction

The listener provided will be called when **wl\_client** destroy is nearly complete, after all of that client's resources have been destroyed.

There is no requirement to remove the link of the **wl\_listener** when the signal is emitted.

**Since**

1\.22.0

### void wl\_client\_add\_destroy\_listener (struct wl\_client \* client, struct wl\_listener \* listener)

Add a listener to be called at the beginning of **wl\_client** destruction

The listener provided will be called when **wl\_client** destroy has begun, before any of that client's resources have been destroyed.

There is no requirement to remove the link of the **wl\_listener** when the signal is emitted.

### void wl\_client\_add\_resource\_created\_listener (struct wl\_client \* client, struct wl\_listener \* listener)

Add a listener for the client's resource creation signal

**Parameters**

*client* The client object \
 *listener* The listener to be added

When a new resource is created for this client the listener will be notified, carrying the new resource as the data argument.

### void wl\_client\_flush (struct wl\_client \* client)

Flush pending events to the client

**Parameters**

*client* The client object

Events sent to clients are queued in a buffer and written to the socket later - typically when the compositor has handled all requests and goes back to block in the event loop. This function flushes all queued up events for a client immediately.

### void wl\_client\_for\_each\_resource (struct wl\_client \* client, wl\_client\_for\_each\_resource\_iterator\_func\_t iterator, void \* user\_data)

Iterate over all the resources of a client

**Parameters**

*client* The client object \
 *iterator* The iterator function \
 *user\_data* The user data pointer

The function pointed by *iterator* will be called for each resource owned by the client. The *user\_data* will be passed as the second argument of the iterator function. If the *iterator* function returns *WL\_ITERATOR\_CONTINUE* the iteration will continue, if it returns *WL\_ITERATOR\_STOP* it will stop.

Creating and destroying resources while iterating is safe, but new resources may or may not be picked up by the iterator.

**See also**

**wl\_iterator\_result**

### struct wl\_client \* wl\_client\_from\_link (struct wl\_list \* link)

Get a **wl\_client** by its link

**Parameters**

**link The link of a wl\_client**

**See also**

**wl\_client\_for\_each()**

**wl\_display\_get\_client\_list()**

**wl\_client\_get\_link()**

### void wl\_client\_get\_credentials (const struct wl\_client \* client, pid\_t \* pid, uid\_t \* uid, gid\_t \* gid)

**Return Unix credentials for the client**

**Parameters**

*client* **The display object** \
 **pid Returns the process ID** \
 **uid Returns the user ID** \
 **gid Returns the group ID**

**This function returns the process ID, the user ID and the group ID for the given client. The credentials come from getsockopt() with SO\_PEERCRED, on the client socket fd. All the pointers can be NULL, if the caller is not interested in a particular ID.**

**Note, process IDs are subject to race conditions and are not a reliable way to identify a client.**

**Be aware that for clients that a compositor forks and execs and then connects using socketpair(), this function will return the credentials for the compositor. The credentials for the socketpair are set at creation time in the compositor.**

### struct wl\_display \* wl\_client\_get\_display (struct wl\_client \* client)

**Get the display object for the given client**

**Parameters**

*client* **The client object**

**Returns**

**The display object the client is associated with.**

### int wl\_client\_get\_fd (struct wl\_client \* client)

**Get the file descriptor for the client**

**Parameters**

*client* **The display object**

**Returns**

**The file descriptor to use for the connection**

**This function returns the file descriptor for the given client.**

**Be sure to use the file descriptor from the client for inspection only. If the caller does anything to the file descriptor that changes its state, it will likely cause problems.**

**See also wl\_client\_get\_credentials(). It is recommended that you evaluate whether wl\_client\_get\_credentials() can be applied to your use case instead of this function.**

**If you would like to distinguish just between the client and the compositor itself from the client's request, it can be done by getting the client credentials and by checking the PID of the client and the compositor's PID. Regarding the case in which the socketpair() is being used, you need to be careful. Please note the documentation for wl\_client\_get\_credentials().**

**This function can be used for a compositor to validate a request from a client if there are additional information provided from the client's file descriptor. For instance, suppose you can get the security contexts from the client's file descriptor. The compositor can validate the client's request with the contexts and make a decision whether it permits or deny it.**

### struct wl\_list \* wl\_client\_get\_link (struct wl\_client \* client)

**Get the link by which a client is inserted in the client list**

**Parameters**

*client* **The client object**

**See also**

**wl\_client\_for\_each()**

**wl\_display\_get\_client\_list()**

**wl\_client\_from\_link()**

### struct wl\_resource \* wl\_client\_get\_object (struct wl\_client \* client, uint32\_t id)

**Look up an object in the client name space**

**Parameters**

*client* **The client object** \
 *id* **The object id**

**Returns**

**The object or NULL if there is not object for the given ID**

**This looks up an object in the client object name space by its object ID.**

### void wl\_client\_post\_implementation\_error (struct wl\_client \* client, char const \* msg, ...)

**Report an internal server error**

**Parameters**

*client* **The client object** \
 *msg* **A printf-style format string** \
 *...* **Format string arguments**

**Report an unspecified internal implementation error and disconnect the client.**

### void wl\_client\_set\_max\_buffer\_size (struct wl\_client \* client, size\_t max\_buffer\_size)

**Adjust the maximum size of the client connection buffers**

**Parameters**

*client* **The client object** \
 *max\_buffer\_size* **The maximum size of the connection buffers**

**The actual size of the connection buffers is a power of two, the requested** *max\_buffer\_size* **is therefore rounded up to the nearest power of two value.**

**Lowering the maximum size may not take effect immediately if the current content of the buffer does not fit within the new size limit.**

**The minimum buffer size is 4096. The default buffers size can be set using wl\_display\_set\_default\_max\_buffer\_size().**

**See also**

**wl\_display\_set\_default\_max\_buffer\_size()**

**Since**

**1.22.90**

## Field Documentation

### struct wl\_connection\* wl\_client::connection

### void\* wl\_client::data

### wl\_user\_data\_destroy\_func\_t wl\_client::data\_dtor

### struct wl\_priv\_signal wl\_client::destroy\_late\_signal

### struct wl\_priv\_signal wl\_client::destroy\_signal

### struct wl\_display\* wl\_client::display

### struct wl\_resource\* wl\_client::display\_resource

### bool wl\_client::error

### gid\_t wl\_client::gid

### struct wl\_list wl\_client::link

### struct wl\_map wl\_client::objects

### pid\_t wl\_client::pid

### struct wl\_priv\_signal wl\_client::resource\_created\_signal

### struct wl\_event\_source\* wl\_client::source

### uid\_t wl\_client::uid

## Author

**Generated automatically by Doxygen for Wayland from the source code.**
