aws-crt-cpp
SocketOptions.h
Go to the documentation of this file.
1 #pragma once
2 /*
3  * Copyright 2010-2019 Amazon.com, Inc. or its affiliates. All Rights Reserved.
4  *
5  * Licensed under the Apache License, Version 2.0 (the "License").
6  * You may not use this file except in compliance with the License.
7  * A copy of the License is located at
8  *
9  * http://aws.amazon.com/apache2.0
10  *
11  * or in the "license" file accompanying this file. This file is distributed
12  * on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
13  * express or implied. See the License for the specific language governing
14  * permissions and limitations under the License.
15  */
16 
17 #include <aws/crt/Exports.h>
18 
19 #include <aws/io/socket.h>
20 
21 namespace Aws
22 {
23  namespace Crt
24  {
25  namespace Io
26  {
27  enum class SocketType
28  {
34  Stream = AWS_SOCKET_STREAM,
40  Dgram = AWS_SOCKET_DGRAM,
41  };
42  enum class SocketDomain
43  {
44  IPv4 = AWS_SOCKET_IPV4,
45  IPv6 = AWS_SOCKET_IPV6,
49  Local = AWS_SOCKET_LOCAL,
50  };
55  {
56  public:
57  SocketOptions();
58  SocketOptions(const SocketOptions &rhs) = default;
59  SocketOptions(SocketOptions &&rhs) = default;
60 
61  SocketOptions &operator=(const SocketOptions &rhs) = default;
67  void SetSocketType(SocketType type) { options.type = (enum aws_socket_type)type; }
68  SocketType GetSocketType() const { return (SocketType)options.type; }
73  void SetSocketDomain(SocketDomain domain) { options.domain = (enum aws_socket_domain)domain; }
74  SocketDomain GetSocketDomain() const { return (SocketDomain)options.domain; }
79  void SetConnectTimeoutMs(uint32_t timeout) { options.connect_timeout_ms = timeout; }
80  uint32_t GetConnectTimeoutMs() const { return options.connect_timeout_ms; }
86  void SetKeepAliveIntervalSec(uint16_t keepAliveInterval)
87  {
88  options.keep_alive_interval_sec = keepAliveInterval;
89  }
90  uint16_t GetKeepAliveIntervalSec() const { return options.keep_alive_interval_sec; }
96  void SetKeepAliveTimeoutSec(uint16_t keepAliveTimeout)
97  {
98  options.keep_alive_timeout_sec = keepAliveTimeout;
99  }
100  uint16_t GetKeepAliveTimeoutSec() const { return options.keep_alive_timeout_sec; }
106  void SetKeepAliveMaxFailedProbes(uint16_t maxProbes)
107  {
108  options.keep_alive_max_failed_probes = maxProbes;
109  }
110  uint16_t GetKeepAliveMaxFailedProbes() const { return options.keep_alive_max_failed_probes; }
115  void SetKeepAlive(bool keepAlive) { options.keepalive = keepAlive; }
116  bool GetKeepAlive() const { return options.keepalive; }
118  aws_socket_options &GetImpl() { return options; }
120  const aws_socket_options &GetImpl() const { return options; }
121 
122  private:
123  aws_socket_options options;
124  };
125  } // namespace Io
126  } // namespace Crt
127 } // namespace Aws
Aws::Crt::Io::SocketOptions::SetKeepAliveTimeoutSec
void SetKeepAliveTimeoutSec(uint16_t keepAliveTimeout)
Definition: SocketOptions.h:96
Aws::Crt::Io::SocketOptions::SetSocketType
void SetSocketType(SocketType type)
Definition: SocketOptions.h:67
Aws::Crt::Io::SocketOptions::GetKeepAliveMaxFailedProbes
uint16_t GetKeepAliveMaxFailedProbes() const
Definition: SocketOptions.h:110
Aws::Crt::Io::SocketOptions::GetKeepAlive
bool GetKeepAlive() const
Definition: SocketOptions.h:116
Aws::Crt::Io::SocketOptions
Definition: SocketOptions.h:55
Aws::Crt::Io::SocketOptions::operator=
SocketOptions & operator=(SocketOptions &&rhs)=default
Aws::Crt::Io::SocketOptions::GetSocketType
SocketType GetSocketType() const
Definition: SocketOptions.h:68
Aws::Crt::Io::SocketOptions::GetKeepAliveTimeoutSec
uint16_t GetKeepAliveTimeoutSec() const
Definition: SocketOptions.h:100
Aws::Crt::Io::SocketOptions::SocketOptions
SocketOptions(const SocketOptions &rhs)=default
Aws::Crt::Io::SocketOptions::SetKeepAliveMaxFailedProbes
void SetKeepAliveMaxFailedProbes(uint16_t maxProbes)
Definition: SocketOptions.h:106
Aws::Crt::Io::SocketOptions::GetConnectTimeoutMs
uint32_t GetConnectTimeoutMs() const
Definition: SocketOptions.h:80
Aws::Crt::Io::SocketOptions::SetSocketDomain
void SetSocketDomain(SocketDomain domain)
Definition: SocketOptions.h:73
Aws::Crt::Io::SocketType::Stream
@ Stream
Aws::Crt::Io::SocketDomain::Local
@ Local
Aws::Crt::Io::SocketDomain::IPv4
@ IPv4
Aws::Crt::Io::SocketOptions::GetSocketDomain
SocketDomain GetSocketDomain() const
Definition: SocketOptions.h:74
Aws::Crt::Io::SocketOptions::SetConnectTimeoutMs
void SetConnectTimeoutMs(uint32_t timeout)
Definition: SocketOptions.h:79
Aws::Crt::Io::SocketOptions::SocketOptions
SocketOptions()
Definition: SocketOptions.cpp:26
Aws
Definition: Api.h:25
Exports.h
Aws::Crt::Io::SocketOptions::operator=
SocketOptions & operator=(const SocketOptions &rhs)=default
Aws::Crt::Io::SocketOptions::SocketOptions
SocketOptions(SocketOptions &&rhs)=default
Aws::Crt::Io::SocketOptions::SetKeepAliveIntervalSec
void SetKeepAliveIntervalSec(uint16_t keepAliveInterval)
Definition: SocketOptions.h:86
Aws::Crt::Io::SocketDomain::IPv6
@ IPv6
Aws::Crt::Io::SocketOptions::SetKeepAlive
void SetKeepAlive(bool keepAlive)
Definition: SocketOptions.h:115
Aws::Crt::Io::SocketOptions::GetKeepAliveIntervalSec
uint16_t GetKeepAliveIntervalSec() const
Definition: SocketOptions.h:90
Aws::Crt::Io::SocketDomain
SocketDomain
Definition: SocketOptions.h:43
Aws::Crt::Io::SocketType::Dgram
@ Dgram
Aws::type
newitem type
Definition: cJSON.cpp:2209
Aws::Crt::Io::SocketType
SocketType
Definition: SocketOptions.h:28