3 #include "fly/net/socket/concepts.hpp"
4 #include "fly/net/socket/detail/base_socket.hpp"
5 #include "fly/net/socket/types.hpp"
23 template <IPEndpo
int Endpo
intType>
26 public std::enable_shared_from_this<UdpSocket<EndpointType>>
30 using SendCompletion = std::function<void(std::size_t)>;
31 using ReceiveCompletion = std::function<void(std::string)>;
39 explicit UdpSocket(std::shared_ptr<NetworkConfig> config) noexcept;
47 UdpSocket(std::shared_ptr<NetworkConfig> config, IOMode mode) noexcept;
74 std::size_t
send(
const EndpointType &endpoint, std::string_view message);
86 std::size_t
send(std::string_view hostname, port_type port, std::string_view message);
104 send_async(
const EndpointType &endpoint, std::string_view message, SendCompletion &&callback);
123 std::string_view hostname,
125 std::string_view message,
126 SendCompletion &&callback);
165 static std::shared_ptr<UdpSocket> create_socket(
166 const std::shared_ptr<SocketService> &service,
167 std::shared_ptr<NetworkConfig> config);
177 const std::shared_ptr<SocketService> &service,
178 std::shared_ptr<NetworkConfig> config) noexcept;
194 const EndpointType &endpoint,
195 std::string_view message,
196 SendCompletion &&callback,
197 std::size_t bytes_sent,
198 std::size_t total_bytes);
210 void ready_to_receive(ReceiveCompletion &&callback, std::string received);
Definition: socket_service.hpp:26
Definition: udp_socket.hpp:27
UdpSocket & operator=(UdpSocket &&socket) noexcept
Definition: udp_socket.cpp:64
std::size_t send(const EndpointType &endpoint, std::string_view message)
Definition: udp_socket.cpp:71
std::string receive()
Definition: udp_socket.cpp:148
bool send_async(const EndpointType &endpoint, std::string_view message, SendCompletion &&callback)
Definition: udp_socket.cpp:107
bool receive_async(ReceiveCompletion &&callback)
Definition: udp_socket.cpp:170
UdpSocket(std::shared_ptr< NetworkConfig > config) noexcept
Definition: udp_socket.cpp:14
Definition: base_socket.hpp:29
std::size_t packet_size() const
Definition: base_socket.cpp:196
socket_type handle() const
Definition: base_socket.cpp:102
void close()
Definition: base_socket.cpp:146
static std::optional< address_type > hostname_to_address(std::string_view hostname)
Definition: base_socket.cpp:81
std::shared_ptr< fly::net::SocketService > socket_service() const
Definition: base_socket.cpp:182