---
name: "libressl-SSL_set_connect_state"
section: "3"
platform: "linux"
package: "libressl"
version: "4.4.0-1"
release: "Arch Linux 2026-11-01"
platforms: ["linux"]
url: "https://new.carta.tech/libressl-SSL_set_connect_state"
---

# libressl-SSL\_set\_connect\_state(3)

prepare SSL object to work in client or server mode

## NAME

**SSL\_set\_connect\_state**, **SSL\_set\_accept\_state**, **SSL\_is\_server** – prepare SSL object to work in client or server mode

## SYNOPSIS

SSL Library (libssl, -lssl) libcrypto

**#include \<openssl/ssl.h\>**

*void*\

**SSL\_set\_connect\_state**(*SSL \*ssl*);

*void*\

**SSL\_set\_accept\_state**(*SSL \*ssl*);

*int*\

**SSL\_is\_server**(*const SSL \*ssl*);

## DESCRIPTION

**SSL\_set\_connect\_state**() sets *ssl* to work in client mode.

**SSL\_set\_accept\_state**() sets *ssl* to work in server mode.

**SSL\_is\_server**() checks whether *ssl* is set to server mode.

When the *SSL\_CTX* object was created with SSL\_CTX\_new(3), it was either assigned a dedicated client method, a dedicated server method, or a generic method, that can be used for both client and server connections. (The method might have been changed with SSL\_CTX\_set\_ssl\_version(3) or SSL\_set\_ssl\_method(3).)

When beginning a new handshake, the SSL engine must know whether it must call the connect (client) or accept (server) routines. Even though it may be clear from the method chosen whether client or server mode was requested, the handshake routines must be explicitly set.

When using the SSL\_connect(3) or SSL\_accept(3) routines, the correct handshake routines are automatically set. When performing a transparent negotiation using SSL\_write(3) or SSL\_read(3), the handshake routines must be explicitly set in advance using either **SSL\_set\_connect\_state**() or **SSL\_set\_accept\_state**().

If **SSL\_is\_server**() is called before **SSL\_set\_connect\_state**() or **SSL\_set\_accept\_state**() was called either automatically or explicitly, the result depends on what method was used when the *SSL\_CTX* was created. If a generic method or a dedicated server method was passed to SSL\_CTX\_new(3), **SSL\_is\_server**() returns 1; otherwise, it returns 0.

## RETURN VALUES

**SSL\_is\_server**() returns 1 if *ssl* is set to server mode or 0 if it is set to client mode.

## SEE ALSO

[ssl(3)](/ssl/3.md), SSL\_accept(3), SSL\_connect(3), SSL\_CTX\_new(3), SSL\_CTX\_set\_ssl\_version(3), SSL\_do\_handshake(3), SSL\_new(3), SSL\_read(3), SSL\_write(3)

## HISTORY

**SSL\_set\_connect\_state**() and **SSL\_set\_accept\_state**() first appeared in SSLeay 0.6.0 and have been available since OpenBSD 2.4.

**SSL\_is\_server**() first appeared in OpenSSL 1.0.2 and has been available since OpenBSD 6.3.
