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