| 1 |
.\" -*- mode: troff; coding: utf-8 -*- |
| 2 |
.\" Automatically generated by Pod::Man 5.0102 (Pod::Simple 3.45) |
| 3 |
.\" |
| 4 |
.\" Standard preamble: |
| 5 |
.\" ======================================================================== |
| 6 |
.de Sp \" Vertical space (when we can't use .PP) |
| 7 |
.if t .sp .5v |
| 8 |
.if n .sp |
| 9 |
.. |
| 10 |
.de Vb \" Begin verbatim text |
| 11 |
.ft CW |
| 12 |
.nf |
| 13 |
.ne \\$1 |
| 14 |
.. |
| 15 |
.de Ve \" End verbatim text |
| 16 |
.ft R |
| 17 |
.fi |
| 18 |
.. |
| 19 |
.\" \*(C` and \*(C' are quotes in nroff, nothing in troff, for use with C<>. |
| 20 |
.ie n \{\ |
| 21 |
. ds C` "" |
| 22 |
. ds C' "" |
| 23 |
'br\} |
| 24 |
.el\{\ |
| 25 |
. ds C` |
| 26 |
. ds C' |
| 27 |
'br\} |
| 28 |
.\" |
| 29 |
.\" Escape single quotes in literal strings from groff's Unicode transform. |
| 30 |
.ie \n(.g .ds Aq \(aq |
| 31 |
.el .ds Aq ' |
| 32 |
.\" |
| 33 |
.\" If the F register is >0, we'll generate index entries on stderr for |
| 34 |
.\" titles (.TH), headers (.SH), subsections (.SS), items (.Ip), and index |
| 35 |
.\" entries marked with X<> in POD. Of course, you'll have to process the |
| 36 |
.\" output yourself in some meaningful fashion. |
| 37 |
.\" |
| 38 |
.\" Avoid warning from groff about undefined register 'F'. |
| 39 |
.de IX |
| 40 |
.. |
| 41 |
.nr rF 0 |
| 42 |
.if \n(.g .if rF .nr rF 1 |
| 43 |
.if (\n(rF:(\n(.g==0)) \{\ |
| 44 |
. if \nF \{\ |
| 45 |
. de IX |
| 46 |
. tm Index:\\$1\t\\n%\t"\\$2" |
| 47 |
.. |
| 48 |
. if !\nF==2 \{\ |
| 49 |
. nr % 0 |
| 50 |
. nr F 2 |
| 51 |
. \} |
| 52 |
. \} |
| 53 |
.\} |
| 54 |
.rr rF |
| 55 |
.\" ======================================================================== |
| 56 |
.\" |
| 57 |
.IX Title "BIO_CONNECT 3SSL" |
| 58 |
.TH BIO_CONNECT 3SSL 2026-04-07 3.6.2 OpenSSL |
| 59 |
.\" For nroff, turn off justification. Always turn off hyphenation; it makes |
| 60 |
.\" way too many mistakes in technical documents. |
| 61 |
.if n .ad l |
| 62 |
.nh |
| 63 |
.SH NAME |
| 64 |
BIO_socket, BIO_bind, BIO_connect, BIO_listen, BIO_accept_ex, BIO_closesocket \- BIO |
| 65 |
socket communication setup routines |
| 66 |
.SH SYNOPSIS |
| 67 |
.IX Header "SYNOPSIS" |
| 68 |
.Vb 1 |
| 69 |
\& #include <openssl/bio.h> |
| 70 |
\& |
| 71 |
\& int BIO_socket(int domain, int socktype, int protocol, int options); |
| 72 |
\& int BIO_bind(int sock, const BIO_ADDR *addr, int options); |
| 73 |
\& int BIO_connect(int sock, const BIO_ADDR *addr, int options); |
| 74 |
\& int BIO_listen(int sock, const BIO_ADDR *addr, int options); |
| 75 |
\& int BIO_accept_ex(int accept_sock, BIO_ADDR *peer, int options); |
| 76 |
\& int BIO_closesocket(int sock); |
| 77 |
.Ve |
| 78 |
.SH DESCRIPTION |
| 79 |
.IX Header "DESCRIPTION" |
| 80 |
\&\fBBIO_socket()\fR creates a socket in the domain \fBdomain\fR, of type |
| 81 |
\&\fBsocktype\fR and \fBprotocol\fR. Socket \fBoptions\fR are currently unused, |
| 82 |
but is present for future use. |
| 83 |
.PP |
| 84 |
\&\fBBIO_bind()\fR binds the source address and service to a socket and |
| 85 |
may be useful before calling \fBBIO_connect()\fR. The options may include |
| 86 |
\&\fBBIO_SOCK_REUSEADDR\fR, which is described in "FLAGS" below. |
| 87 |
.PP |
| 88 |
\&\fBBIO_connect()\fR connects \fBsock\fR to the address and service given by |
| 89 |
\&\fBaddr\fR. Connection \fBoptions\fR may be zero or any combination of |
| 90 |
\&\fBBIO_SOCK_KEEPALIVE\fR, \fBBIO_SOCK_NONBLOCK\fR and \fBBIO_SOCK_NODELAY\fR. |
| 91 |
The flags are described in "FLAGS" below. |
| 92 |
.PP |
| 93 |
\&\fBBIO_listen()\fR has \fBsock\fR start listening on the address and service |
| 94 |
given by \fBaddr\fR. Connection \fBoptions\fR may be zero or any |
| 95 |
combination of \fBBIO_SOCK_KEEPALIVE\fR, \fBBIO_SOCK_NONBLOCK\fR, |
| 96 |
\&\fBBIO_SOCK_NODELAY\fR, \fBBIO_SOCK_REUSEADDR\fR and \fBBIO_SOCK_V6_ONLY\fR. |
| 97 |
The flags are described in "FLAGS" below. |
| 98 |
.PP |
| 99 |
\&\fBBIO_accept_ex()\fR waits for an incoming connections on the given |
| 100 |
socket \fBaccept_sock\fR. When it gets a connection, the address and |
| 101 |
port of the peer gets stored in \fBpeer\fR if that one is non-NULL. |
| 102 |
Accept \fBoptions\fR may be zero or \fBBIO_SOCK_NONBLOCK\fR, and is applied |
| 103 |
on the accepted socket. The flags are described in "FLAGS" below. |
| 104 |
.PP |
| 105 |
\&\fBBIO_closesocket()\fR closes \fBsock\fR. |
| 106 |
.SH FLAGS |
| 107 |
.IX Header "FLAGS" |
| 108 |
.IP BIO_SOCK_KEEPALIVE 4 |
| 109 |
.IX Item "BIO_SOCK_KEEPALIVE" |
| 110 |
Enables regular sending of keep-alive messages. |
| 111 |
.IP BIO_SOCK_NONBLOCK 4 |
| 112 |
.IX Item "BIO_SOCK_NONBLOCK" |
| 113 |
Sets the socket to nonblocking mode. |
| 114 |
.IP BIO_SOCK_NODELAY 4 |
| 115 |
.IX Item "BIO_SOCK_NODELAY" |
| 116 |
Corresponds to \fBTCP_NODELAY\fR, and disables the Nagle algorithm. With |
| 117 |
this set, any data will be sent as soon as possible instead of being |
| 118 |
buffered until there's enough for the socket to send out in one go. |
| 119 |
.IP BIO_SOCK_REUSEADDR 4 |
| 120 |
.IX Item "BIO_SOCK_REUSEADDR" |
| 121 |
Try to reuse the address and port combination for a recently closed |
| 122 |
port. |
| 123 |
.IP BIO_SOCK_V6_ONLY 4 |
| 124 |
.IX Item "BIO_SOCK_V6_ONLY" |
| 125 |
When creating an IPv6 socket, make it only listen for IPv6 addresses |
| 126 |
and not IPv4 addresses mapped to IPv6. |
| 127 |
.IP BIO_SOCK_TFO 4 |
| 128 |
.IX Item "BIO_SOCK_TFO" |
| 129 |
Enables TCP Fast Open on the socket. Uses appropriate APIs on |
| 130 |
supported operating systems, including Linux, macOS and FreeBSD. Can |
| 131 |
be used with \fBBIO_connect()\fR, \fBBIO_set_conn_mode()\fR, \fBBIO_set_bind_mode()\fR, |
| 132 |
and \fBBIO_listen()\fR. |
| 133 |
On Linux kernels before 4.14, use \fBBIO_set_conn_address()\fR to specify |
| 134 |
the peer address before starting the TLS handshake. |
| 135 |
.PP |
| 136 |
These flags are bit flags, so they are to be combined with the |
| 137 |
\&\f(CW\*(C`|\*(C'\fR operator, for example: |
| 138 |
.PP |
| 139 |
.Vb 1 |
| 140 |
\& BIO_connect(sock, addr, BIO_SOCK_KEEPALIVE | BIO_SOCK_NONBLOCK); |
| 141 |
.Ve |
| 142 |
.SH "RETURN VALUES" |
| 143 |
.IX Header "RETURN VALUES" |
| 144 |
\&\fBBIO_socket()\fR returns the socket number on success or \fBINVALID_SOCKET\fR |
| 145 |
(\-1) on error. When an error has occurred, the OpenSSL error stack |
| 146 |
will hold the error data and errno has the system error. |
| 147 |
.PP |
| 148 |
\&\fBBIO_bind()\fR, \fBBIO_connect()\fR and \fBBIO_listen()\fR return 1 on success or 0 on error. |
| 149 |
When an error has occurred, the OpenSSL error stack will hold the error |
| 150 |
data and errno has the system error. |
| 151 |
.PP |
| 152 |
\&\fBBIO_accept_ex()\fR returns the accepted socket on success or |
| 153 |
\&\fBINVALID_SOCKET\fR (\-1) on error. When an error has occurred, the |
| 154 |
OpenSSL error stack will hold the error data and errno has the system |
| 155 |
error. |
| 156 |
.SH "SEE ALSO" |
| 157 |
.IX Header "SEE ALSO" |
| 158 |
\&\fBBIO_ADDR\fR\|(3) |
| 159 |
.SH HISTORY |
| 160 |
.IX Header "HISTORY" |
| 161 |
\&\fBBIO_gethostname()\fR, \fBBIO_get_port()\fR, \fBBIO_get_host_ip()\fR, |
| 162 |
\&\fBBIO_get_accept_socket()\fR and \fBBIO_accept()\fR were deprecated in OpenSSL 1.1.0. |
| 163 |
Use the functions described above instead. |
| 164 |
.SH COPYRIGHT |
| 165 |
.IX Header "COPYRIGHT" |
| 166 |
Copyright 2016\-2022 The OpenSSL Project Authors. All Rights Reserved. |
| 167 |
.PP |
| 168 |
Licensed under the Apache License 2.0 (the "License"). You may not use |
| 169 |
this file except in compliance with the License. You can obtain a copy |
| 170 |
in the file LICENSE in the source distribution or at |
| 171 |
<https://www.openssl.org/source/license.html>. |