unilink  0.4.3
A simple C++ library for unified async communication
udp_config.hpp
Go to the documentation of this file.
1 /*
2  * Copyright 2025 Jinwoo Sung
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 
17 #pragma once
18 
19 #include <cstdint>
20 #include <optional>
21 #include <string>
22 
24 
25 namespace unilink {
26 namespace config {
27 
28 struct UdpConfig {
29  std::string local_address = "0.0.0.0";
30  uint16_t local_port = 0;
31  std::optional<std::string> remote_address;
32  std::optional<uint16_t> remote_port;
34  bool enable_memory_pool = true;
36 
37  bool is_valid() const {
40  return false;
41  }
42  if (remote_address.has_value() != remote_port.has_value()) return false;
43  if (remote_port && *remote_port == 0) return false;
44  return true;
45  }
46 
52  }
53  }
54 };
55 
56 } // namespace config
57 } // namespace unilink