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

# SSL\_set\_connect\_state(3ssl)

functions for manipulating and examining the client or server mode of an SSL object

## NAME

SSL\_set\_connect\_state, SSL\_set\_accept\_state, SSL\_is\_server - functions for manipulating and examining the client or server mode of an SSL object

## SYNOPSIS

```
 #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 if **ssl** is working in server mode.

## NOTES

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\_ex**(3), **SSL\_write**(3), **SSL\_read\_ex**(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()** is called (either automatically or explicitly), the result depends on what method was used when SSL\_CTX was created with **SSL\_CTX\_new**(3). 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\_set\_connect\_state()** and **SSL\_set\_accept\_state()** do not return diagnostic information.

**SSL\_is\_server()** returns 1 if **ssl** is working in server mode or 0 for client mode.

## SEE ALSO

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

## COPYRIGHT

Copyright 2001-2017 The OpenSSL Project Authors. All Rights Reserved.

Licensed under the Apache License 2.0 (the "License").  You may not use this file except in compliance with the License.  You can obtain a copy in the file LICENSE in the source distribution or at \<https://www.openssl.org/source/license.html\>.
