9
3

01_connecting.qbk 1.2 KB

123456789101112131415161718192021222324252627282930313233
  1. [/
  2. Copyright (c) 2016-2019 Vinnie Falco (vinnie dot falco at gmail dot com)
  3. Distributed under the Boost Software License, Version 1.0. (See accompanying
  4. file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
  5. Official repository: https://github.com/boostorg/beast
  6. ]
  7. [section:establishing_connections Connecting]
  8. Before messages can be exchanged, a websocket stream first needs to be
  9. connected, and then to have the websocket handshake performed. The stream
  10. delegates the task of establishing the connection to the next layers.
  11. For example, if the next layer is a connectible stream or socket object,
  12. it can be accessed to call the necessary function for connecting.
  13. Here we make an outbound connection as a client would do.
  14. [code_websocket_1_1]
  15. To accept incoming connections, an acceptor is used. The websocket stream
  16. may be constructed from the socket returned by the acceptor when an
  17. incoming connection is established.
  18. [code_websocket_1_2]
  19. Alternatively, the incoming connection may be accepted directly into
  20. the socket owned by the websocket stream, using this overload of the
  21. acceptor member function.
  22. [code_websocket_1_3]
  23. [endsect]