1=pod 2 3=head1 NAME 4 5BIO_socket, BIO_bind, BIO_connect, BIO_listen, BIO_accept_ex, BIO_closesocket - BIO 6socket communication setup routines 7 8=head1 SYNOPSIS 9 10 #include <openssl/bio.h> 11 12 int BIO_socket(int domain, int socktype, int protocol, int options); 13 int BIO_bind(int sock, const BIO_ADDR *addr, int options); 14 int BIO_connect(int sock, const BIO_ADDR *addr, int options); 15 int BIO_listen(int sock, const BIO_ADDR *addr, int options); 16 int BIO_accept_ex(int accept_sock, BIO_ADDR *peer, int options); 17 int BIO_closesocket(int sock); 18 19=head1 DESCRIPTION 20 21BIO_socket() creates a socket in the domain B<domain>, of type 22B<socktype> and B<protocol>. Socket B<options> are currently unused, 23but is present for future use. 24 25BIO_bind() binds the source address and service to a socket and 26may be useful before calling BIO_connect(). The options may include 27B<BIO_SOCK_REUSEADDR>, which is described in L</FLAGS> below. 28 29BIO_connect() connects B<sock> to the address and service given by 30B<addr>. Connection B<options> may be zero or any combination of 31B<BIO_SOCK_KEEPALIVE>, B<BIO_SOCK_NONBLOCK> and B<BIO_SOCK_NODELAY>. 32The flags are described in L</FLAGS> below. 33 34BIO_listen() has B<sock> start listening on the address and service 35given by B<addr>. Connection B<options> may be zero or any 36combination of B<BIO_SOCK_KEEPALIVE>, B<BIO_SOCK_NONBLOCK>, 37B<BIO_SOCK_NODELAY>, B<BIO_SOCK_REUSEADDR> and B<BIO_SOCK_V6_ONLY>. 38The flags are described in L</FLAGS> below. 39 40BIO_accept_ex() waits for an incoming connections on the given 41socket B<accept_sock>. When it gets a connection, the address and 42port of the peer gets stored in B<peer> if that one is non-NULL. 43Accept B<options> may be zero or B<BIO_SOCK_NONBLOCK>, and is applied 44on the accepted socket. The flags are described in L</FLAGS> below. 45 46BIO_closesocket() closes B<sock>. 47 48=head1 FLAGS 49 50=over 4 51 52=item BIO_SOCK_KEEPALIVE 53 54Enables regular sending of keep-alive messages. 55 56=item BIO_SOCK_NONBLOCK 57 58Sets the socket to nonblocking mode. 59 60=item BIO_SOCK_NODELAY 61 62Corresponds to B<TCP_NODELAY>, and disables the Nagle algorithm. With 63this set, any data will be sent as soon as possible instead of being 64buffered until there's enough for the socket to send out in one go. 65 66=item BIO_SOCK_REUSEADDR 67 68Try to reuse the address and port combination for a recently closed 69port. 70 71=item BIO_SOCK_V6_ONLY 72 73When creating an IPv6 socket, make it only listen for IPv6 addresses 74and not IPv4 addresses mapped to IPv6. 75 76=back 77 78These flags are bit flags, so they are to be combined with the 79C<|> operator, for example: 80 81 BIO_connect(sock, addr, BIO_SOCK_KEEPALIVE | BIO_SOCK_NONBLOCK); 82 83=head1 RETURN VALUES 84 85BIO_socket() returns the socket number on success or B<INVALID_SOCKET> 86(-1) on error. When an error has occurred, the OpenSSL error stack 87will hold the error data and errno has the system error. 88 89BIO_bind(), BIO_connect() and BIO_listen() return 1 on success or 0 on error. 90When an error has occurred, the OpenSSL error stack will hold the error 91data and errno has the system error. 92 93BIO_accept_ex() returns the accepted socket on success or 94B<INVALID_SOCKET> (-1) on error. When an error has occurred, the 95OpenSSL error stack will hold the error data and errno has the system 96error. 97 98=head1 SEE ALSO 99 100L<BIO_ADDR(3)> 101 102=head1 HISTORY 103 104BIO_gethostname(), BIO_get_port(), BIO_get_host_ip(), 105BIO_get_accept_socket() and BIO_accept() were deprecated in OpenSSL 1.1.0. 106Use the functions described above instead. 107 108=head1 COPYRIGHT 109 110Copyright 2016-2020 The OpenSSL Project Authors. All Rights Reserved. 111 112Licensed under the Apache License 2.0 (the "License"). You may not use 113this file except in compliance with the License. You can obtain a copy 114in the file LICENSE in the source distribution or at 115L<https://www.openssl.org/source/license.html>. 116 117=cut 118