---
name: "libressl-BIO_s_socket"
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-BIO_s_socket"
---

# libressl-BIO\_s\_socket(3)

socket BIO

## NAME

**BIO\_s\_socket**, **BIO\_new\_socket** – socket BIO

## SYNOPSIS

Crypto Library (libcrypto, -lcrypto)

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

*const* *BIO\_METHOD* *\**\

**BIO\_s\_socket**(*void*);

*BIO* *\**\

**BIO\_new\_socket**(*int sock*, *int close\_flag*);

## DESCRIPTION

**BIO\_s\_socket**() returns the socket BIO method. This is a wrapper around the platform's socket routines.

BIO\_read(3) and BIO\_write(3) read or write the underlying socket. BIO\_puts(3) is supported but BIO\_gets(3) is not.

If the close flag is set, then the socket is shut down and closed when the BIO is freed.

**BIO\_new\_socket**() returns a socket BIO using *sock* and *close\_flag*.

Socket BIOs also support any relevant functionality of file descriptor BIOs.

The reason for having separate file descriptor and socket BIOs is that on some platforms, sockets are not file descriptors and use distinct I/O routines. Windows is one such platform. Any code mixing the two will not work on all platforms.

## RETURN VALUES

**BIO\_s\_socket**() returns the socket BIO method.

**BIO\_new\_socket**() returns the newly allocated BIO or NULL if an error occurred.

When called on a socket BIO object, BIO\_method\_type(3) returns the constant BIO\_TYPE\_SOCKET and BIO\_method\_name(3) returns a pointer to the static string "socket".

## SEE ALSO

BIO\_get\_fd(3), BIO\_new(3)

## HISTORY

**BIO\_s\_socket**() first appeared in SSLeay 0.6.0. **BIO\_new\_socket**() first appeared in SSLeay 0.8.0. Both functions have been available since OpenBSD 2.4.
