Hazelcast C++ Client
Hazelcast C++ Client Library
socket.h
1 /*
2  * Copyright (c) 2008-2022, Hazelcast, Inc. All Rights Reserved.
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  * http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  */
16 #pragma once
17 
18 #include <boost/asio.hpp>
19 
20 #include "hazelcast/client/config/socket_options.h"
21 #include "hazelcast/client/address.h"
22 
23 #if defined(WIN32) || defined(_WIN32) || defined(WIN64) || defined(_WIN64)
24 #pragma warning(push)
25 #pragma warning(disable : 4251) // for dll export
26 #endif
27 
28 namespace hazelcast {
29 namespace client {
30 namespace connection {
31 class Connection;
32 }
33 
34 namespace spi {
35 namespace impl {
36 class ClientInvocation;
37 }
38 } // namespace spi
39 
40 class HAZELCAST_API socket
41 {
42 public:
43  virtual ~socket() = default;
44 
45  virtual void connect(
46  const std::shared_ptr<connection::Connection> connection) = 0;
47 
48  virtual void async_write(
49  const std::shared_ptr<connection::Connection> connection,
50  const std::shared_ptr<spi::impl::ClientInvocation> invocation) = 0;
51 
52  virtual void close() = 0;
53 
54  virtual address get_address() const = 0;
55 
62  virtual boost::optional<address> local_socket_address() const = 0;
63 
64  virtual const address& get_remote_endpoint() const = 0;
65 
66  virtual boost::asio::io_context::strand& get_executor() noexcept = 0;
67 };
68 } // namespace client
69 } // namespace hazelcast
70 
71 #if defined(WIN32) || defined(_WIN32) || defined(WIN64) || defined(_WIN64)
72 #pragma warning(pop)
73 #endif
Represents an address of a client or member in the cluster.
Definition: address.h:37
virtual boost::optional< address > local_socket_address() const =0
This function is used to obtain the locally bound endpoint of the socket.