---
name: "libssh2_channel_forward_listen_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_forward_listen_ex"
---

# libssh2\_channel\_forward\_listen\_ex(3)

listen to inbound connections

## NAME

libssh2\_channel\_forward\_listen\_ex - listen to inbound connections

## SYNOPSIS

```
#include <libssh2.h>
LIBSSH2_LISTENER *
libssh2_channel_forward_listen_ex(LIBSSH2_SESSION *session,
                                  char *host, int port,
                                  int *bound_port, int queue_maxsize);
LIBSSH2_LISTENER *
libssh2_channel_forward_listen(LIBSSH2_SESSION *session, int port);
```

## DESCRIPTION

Instruct the remote SSH server to begin listening for inbound TCP/IP connections. New connections will be queued by the library until accepted by *[libssh2\_channel\_forward\_accept(3)](/libssh2_channel_forward_accept/3.md)*.

*session* - instance as returned by libssh2\_session\_init().

*host* - specific address to bind to on the remote host. Binding to 0.0.0.0 (default when NULL is passed) will bind to all available addresses.

*port* - port to bind to on the remote host. When 0 is passed, the remote host will select the first available dynamic port.

*bound\_port* - Populated with the actual port bound on the remote host. Useful when requesting dynamic port numbers.

*queue\_maxsize* - Maximum number of pending connections to queue before rejecting further attempts.

*[libssh2\_channel\_forward\_listen(3)](/libssh2_channel_forward_listen/3.md)* is a macro.

## RETURN VALUE

A newly allocated LIBSSH2\_LISTENER instance or NULL on failure.

## ERRORS

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

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

*LIBSSH2\_ERROR\_PROTO* - An invalid SSH protocol response was received on the socket.

*LIBSSH2\_ERROR\_REQUEST\_DENIED* - The remote server refused the request.

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

## SEE ALSO

**[libssh2\_channel\_forward\_accept(3)](/libssh2_channel_forward_accept/3.md)**
