---
name: "libssh2_channel_open_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_open_ex"
---

# libssh2\_channel\_open\_ex(3)

establish a generic session channel

## NAME

libssh2\_channel\_open\_ex - establish a generic session channel

## SYNOPSIS

```
#include <libssh2.h>
LIBSSH2_CHANNEL *
libssh2_channel_open_ex(LIBSSH2_SESSION *session, const char *channel_type,
                        unsigned int channel_type_len,
                        unsigned int window_size,
                        unsigned int packet_size,
                        const char *message, unsigned int message_len);
LIBSSH2_CHANNEL *
libssh2_channel_open_session(session);
```

## DESCRIPTION

*session* - Session instance as returned by **[libssh2\_session\_init\_ex(3)](/libssh2_session_init_ex/3.md)**

*channel\_type* - Channel type to open. Typically one of session, direct-tcpip, or tcpip-forward. The SSH2 protocol allowed for additional types including local, custom channel types.

*channel\_type\_len* - Length of channel\_type

*window\_size* - Maximum amount of unacknowledged data remote host is allowed to send before receiving an SSH\_MSG\_CHANNEL\_WINDOW\_ADJUST packet.

*packet\_size* - Maximum number of bytes remote host is allowed to send in a single SSH\_MSG\_CHANNEL\_DATA or SSG\_MSG\_CHANNEL\_EXTENDED\_DATA packet.

*message* - Additional data as required by the selected channel\_type.

*message\_len* - Length of message parameter.

Allocate a new channel for exchanging data with the server. This method is typically called through its macroized form: **[libssh2\_channel\_open\_session(3)](/libssh2_channel_open_session/3.md)** or via **[libssh2\_channel\_direct\_tcpip(3)](/libssh2_channel_direct_tcpip/3.md)** or **[libssh2\_channel\_forward\_listen(3)](/libssh2_channel_forward_listen/3.md)**

## RETURN VALUE

Pointer to a newly allocated LIBSSH2\_CHANNEL instance, or NULL on errors.

## ERRORS

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

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

*LIBSSH2\_ERROR\_CHANNEL\_FAILURE* -

*LIBSSH2\_ERROR\_EAGAIN* - Marked for non-blocking I/O but the call would block.

## SEE ALSO

Add related functions
