---
name: "libssh2_channel_x11_req_ex"
section: "3"
platform: "linux"
package: "libssh2"
version: "1.11.1-7"
release: "Arch Linux 2026-11-01"
platforms: ["linux"]
url: "https://new.carta.tech/libssh2_channel_x11_req_ex"
---

# libssh2\_channel\_x11\_req\_ex(3)

request an X11 forwarding channel

## NAME

libssh2\_channel\_x11\_req\_ex - request an X11 forwarding channel

## SYNOPSIS

```
#include <libssh2.h>
int
libssh2_channel_x11_req_ex(LIBSSH2_CHANNEL *channel, int single_connection,
                           const char *auth_proto, const char *auth_cookie,
                           int screen_number);
int
libssh2_channel_x11_req(LIBSSH2_CHANNEL *channel,
                        int screen_number);
```

## DESCRIPTION

*channel* - Previously opened channel instance such as returned by **[libssh2\_channel\_open\_ex(3)](/libssh2_channel_open_ex/3.md)**

*single\_connection* - non-zero to only forward a single connection.

*auth\_proto* - X11 authentication protocol to use

*auth\_cookie* - the cookie (hexadecimal encoded).

*screen\_number* - the XLL screen to forward

Request an X11 forwarding on *channel*. To use X11 forwarding, **[libssh2\_session\_callback\_set2(3)](/libssh2_session_callback_set2/3.md)** must first be called to set **LIBSSH2\_CALLBACK\_X11**. This callback will be invoked when the remote host accepts the X11 forwarding.

## RETURN VALUE

Return 0 on success or negative on failure. It returns LIBSSH2\_ERROR\_EAGAIN when it would otherwise block. While LIBSSH2\_ERROR\_EAGAIN is a negative number, it is not really a failure per se.

## ERRORS

*LIBSSH2\_ERROR\_ALLOC* - An internal memory allocation call failed.

*LIBSSH2\_ERROR\_SOCKET\_SEND* - Unable to send data on socket.

*LIBSSH2\_ERROR\_CHANNEL\_REQUEST\_DENIED* -

## SEE ALSO

**[libssh2\_channel\_open\_ex(3)](/libssh2_channel_open_ex/3.md)** **[libssh2\_session\_callback\_set2(3)](/libssh2_session_callback_set2/3.md)**
