BIO_CONNECT(3ossl)
π NAME π
Hey bestie, welcome to the 3ossl manual page for the socket setup squad! Meet BIO_socket, BIO_bind, BIO_connect, BIO_listen, BIO_accept_ex, and BIO_closesocket β together they're the BIO socket communication setup routines. π
β¨
π SYNOPSIS π
#include <openssl/bio.h>
int BIO_socket(int domain, int socktype, int protocol, int options);
int BIO_bind(int sock, const BIO_ADDR *addr, int options);
int BIO_connect(int sock, const BIO_ADDR *addr, int options);
int BIO_listen(int sock, const BIO_ADDR *addr, int options);
int BIO_accept_ex(int accept_sock, BIO_ADDR *peer, int options);
int BIO_closesocket(int sock);
πΈ DESCRIPTION πΈ
Okay so here's the whole vibe, one function at a time:
BIO_socket()β creates a socket in the domain domain, of type socktype, and with protocol. Theoptionsargument is currently unused, but it's present for future use. Lowkey just sitting there being iconic for later. π«ΆBIO_bind()β binds the source address and service to a socket, and it may be useful before callingBIO_connect(). Theoptionsmay includeBIO_SOCK_REUSEADDR, which is described in FLAGS below. β¨BIO_connect()β connectssockto the address and service given byaddr. Connection options may be zero or any combination ofBIO_SOCK_KEEPALIVE,BIO_SOCK_NONBLOCK, andBIO_SOCK_NODELAY. The flags are described in FLAGS below. πBIO_listen()β hassockstart listening on the address and service given byaddr. Connection options may be zero or any combination ofBIO_SOCK_KEEPALIVE,BIO_SOCK_NONBLOCK,BIO_SOCK_NODELAY,BIO_SOCK_REUSEADDR, andBIO_SOCK_V6_ONLY. The flags are described in FLAGS below. πBIO_accept_ex()β waits for incoming connections on the given socketaccept_sock. When it gets a connection, the address and port of the peer get stored inpeerif that one is non-NULL. Accept options may be zero orBIO_SOCK_NONBLOCK, and it's applied on the accepted socket. The flags are described in FLAGS below. π¦BIO_closesocket()β closessock. That's it. That's the whole job. π
π FLAGS π
These are the little option besties you can pass around. They're bit flags, so combine them with the "|" operator, bestie.
BIO_SOCK_KEEPALIVEβ enables regular sending of keep-alive messages. πBIO_SOCK_NONBLOCKβ sets the socket to nonblocking mode. No waiting around, main character energy. β‘BIO_SOCK_NODELAYβ corresponds toTCP_NODELAY, and disables the Nagle algorithm. With this set, any data will be sent as soon as possible instead of being buffered until there's enough for the socket to send out in one go. Fr fr, no buffering drama. π₯BIO_SOCK_REUSEADDRβ try to reuse the address and port combination for a recently closed port. Recycling, but make it socket behavior. β»οΈBIO_SOCK_V6_ONLYβ when creating an IPv6 socket, make it only listen for IPv6 addresses and not IPv4 addresses mapped to IPv6. Strictly IPv6, no imposters. π«BIO_SOCK_TFOβ enables TCP Fast Open on the socket. Uses appropriate APIs on supported operating systems, including Linux, macOS and FreeBSD. Can be used withBIO_connect(),BIO_set_conn_mode(),BIO_set_bind_mode(), andBIO_listen(). On Linux kernels before4.14, useBIO_set_conn_address()to specify the peer address before starting the TLS handshake. Speedy handshake vibes, iykyk. π
These flags are bit flags, so they are to be combined with the "|" operator, for example:
BIO_connect(sock, addr, BIO_SOCK_KEEPALIVE | BIO_SOCK_NONBLOCK);
π RETURN VALUES π
BIO_socket()returns the socket number on success orINVALID_SOCKET(-1) on error. When an error has occurred, the OpenSSL error stack will hold the error data anderrnohas the system error. πBIO_bind(),BIO_connect(), andBIO_listen()return1on success or0on error. When an error has occurred, the OpenSSL error stack will hold the error data anderrnohas the system error. π«ΆBIO_accept_ex()returns the accepted socket on success orINVALID_SOCKET(-1) on error. When an error has occurred, the OpenSSL error stack will hold the error data anderrnohas the system error. π
π¦ SEE ALSO π¦
β HISTORY β
BIO_gethostname(), BIO_get_port(), BIO_get_host_ip(), BIO_get_accept_socket() and BIO_accept() were deprecated in OpenSSL 1.1.0. Use the functions described above instead. We love an upgrade era. β¨
π COPYRIGHT π
Copyright 2016-2022 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>.
Catch you later, bestie β this iconic little page is from version 3.5.0, dated 2026-09-25, and it's literally BIO_CONNECT(3ossl). πβ¨π
π¦ where this page comes from
- opensuse-leap 16.0: openssl-3-doc 3.5.0-160000.11.1 Β· Apache-2.0
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash-1017 on : a language model's rewrite of the original, under its terms