AWS IoT Device SDK C++ v2  1.34.0
AWS IoT Device SDK C++ v2
SocketOptions.h
Go to the documentation of this file.
1 #pragma once
2 
7 #include <aws/crt/Exports.h>
8 
9 #include <aws/io/socket.h>
10 
11 namespace Aws
12 {
13  namespace Crt
14  {
15  namespace Io
16  {
17  enum class SocketType
18  {
24  Stream = AWS_SOCKET_STREAM,
25 
31  Dgram = AWS_SOCKET_DGRAM,
32  };
33 
34  enum class SocketDomain
35  {
36  IPv4 = AWS_SOCKET_IPV4,
37  IPv6 = AWS_SOCKET_IPV6,
41  Local = AWS_SOCKET_LOCAL,
42  };
43 
48  {
49  public:
50  SocketOptions();
51  SocketOptions(const SocketOptions &rhs) = default;
52  SocketOptions(SocketOptions &&rhs) = default;
53 
54  SocketOptions &operator=(const SocketOptions &rhs) = default;
56 
61  void SetSocketType(SocketType type) { options.type = (enum aws_socket_type)type; }
62 
66  SocketType GetSocketType() const { return (SocketType)options.type; }
67 
72  void SetSocketDomain(SocketDomain domain) { options.domain = (enum aws_socket_domain)domain; }
73 
77  SocketDomain GetSocketDomain() const { return (SocketDomain)options.domain; }
78 
83  void SetConnectTimeoutMs(uint32_t timeout) { options.connect_timeout_ms = timeout; }
84 
88  uint32_t GetConnectTimeoutMs() const { return options.connect_timeout_ms; }
89 
95  void SetKeepAliveIntervalSec(uint16_t keepAliveInterval)
96  {
97  options.keep_alive_interval_sec = keepAliveInterval;
98  }
99 
103  uint16_t GetKeepAliveIntervalSec() const { return options.keep_alive_interval_sec; }
104 
110  void SetKeepAliveTimeoutSec(uint16_t keepAliveTimeout)
111  {
112  options.keep_alive_timeout_sec = keepAliveTimeout;
113  }
114 
119  uint16_t GetKeepAliveTimeoutSec() const { return options.keep_alive_timeout_sec; }
120 
126  void SetKeepAliveMaxFailedProbes(uint16_t maxProbes)
127  {
128  options.keep_alive_max_failed_probes = maxProbes;
129  }
130 
134  uint16_t GetKeepAliveMaxFailedProbes() const { return options.keep_alive_max_failed_probes; }
135 
140  void SetKeepAlive(bool keepAlive) { options.keepalive = keepAlive; }
141 
145  bool GetKeepAlive() const { return options.keepalive; }
146 
148  aws_socket_options &GetImpl() { return options; }
150  const aws_socket_options &GetImpl() const { return options; }
151 
152  private:
153  aws_socket_options options;
154  };
155  } // namespace Io
156  } // namespace Crt
157 } // namespace Aws
Aws::Crt::Io::SocketOptions::SetSocketDomain
void SetSocketDomain(SocketDomain domain)
Definition: SocketOptions.h:72
Aws::Crt::Io::SocketOptions::GetKeepAliveTimeoutSec
uint16_t GetKeepAliveTimeoutSec() const
Definition: SocketOptions.h:119
Aws::Crt::Io::SocketOptions::SetKeepAliveMaxFailedProbes
void SetKeepAliveMaxFailedProbes(uint16_t maxProbes)
Definition: SocketOptions.h:126
Aws::Crt::Io::SocketOptions::operator=
SocketOptions & operator=(SocketOptions &&rhs)=default
Aws::Crt::Io::SocketOptions::SetConnectTimeoutMs
void SetConnectTimeoutMs(uint32_t timeout)
Definition: SocketOptions.h:83
Aws::Crt::Io::SocketOptions::GetConnectTimeoutMs
uint32_t GetConnectTimeoutMs() const
Definition: SocketOptions.h:88
Aws::Crt::Io::SocketOptions::SetKeepAlive
void SetKeepAlive(bool keepAlive)
Definition: SocketOptions.h:140
Aws::Crt::Io::SocketDomain::IPv4
@ IPv4
Aws::Crt::Io::SocketOptions::GetSocketType
SocketType GetSocketType() const
Definition: SocketOptions.h:66
Aws::Crt::Io::SocketOptions::SocketOptions
SocketOptions(const SocketOptions &rhs)=default
Aws::Crt::Io::SocketOptions
Definition: SocketOptions.h:48
Aws::Crt::Io::SocketType::Stream
@ Stream
AWS_CRT_CPP_API
#define AWS_CRT_CPP_API
Definition: Exports.h:37
Aws::Crt::Io::SocketDomain
SocketDomain
Definition: SocketOptions.h:35
Aws
Definition: Allocator.h:11
Aws::Crt::Io::SocketOptions::SocketOptions
SocketOptions(SocketOptions &&rhs)=default
Aws::Crt::Io::SocketOptions::operator=
SocketOptions & operator=(const SocketOptions &rhs)=default
Aws::Crt::Io::SocketOptions::SetSocketType
void SetSocketType(SocketType type)
Definition: SocketOptions.h:61
Exports.h
Aws::Crt::Io::SocketOptions::GetKeepAliveIntervalSec
uint16_t GetKeepAliveIntervalSec() const
Definition: SocketOptions.h:103
Aws::Crt::Io::SocketOptions::GetKeepAliveMaxFailedProbes
uint16_t GetKeepAliveMaxFailedProbes() const
Definition: SocketOptions.h:134
Aws::Crt::Io::SocketOptions::SetKeepAliveTimeoutSec
void SetKeepAliveTimeoutSec(uint16_t keepAliveTimeout)
Definition: SocketOptions.h:110
Aws::Crt::Io::SocketOptions::GetKeepAlive
bool GetKeepAlive() const
Definition: SocketOptions.h:145
Aws::Crt::Io::SocketType
SocketType
Definition: SocketOptions.h:18
Aws::Crt::Io::SocketOptions::GetSocketDomain
SocketDomain GetSocketDomain() const
Definition: SocketOptions.h:77
Aws::Crt::Io::SocketOptions::SetKeepAliveIntervalSec
void SetKeepAliveIntervalSec(uint16_t keepAliveInterval)
Definition: SocketOptions.h:95