BIO_connect.pod 3.4 KB

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