6 #include "../../object.h"
7 #include "../../ustring.h"
8 #include "../ip_end_point.h"
38 async_result_socket(std::any async_state) : async_state_(async_state) {}
39 std::any async_state()
const noexcept
override {
return async_state_;}
40 std::shared_mutex& async_mutex()
override {
return async_mutex_;}
41 bool completed_synchronously()
const noexcept
override {
return false;}
42 bool is_completed()
const noexcept
override {
return is_completed_;};
44 std::any async_state_;
45 bool is_completed_ =
false;
46 std::shared_mutex async_mutex_;
48 std::exception_ptr exception_;
51 class async_result_receive :
public async_result_socket {
53 async_result_receive(std::any async_state) : async_result_socket(async_state) {}
54 std::vector<byte_t> buffer_;
58 class async_result_send :
public async_result_socket {
60 async_result_send(std::any async_state) : async_result_socket(async_state) {}
61 size_t number_of_bytes_sent_;
117 friend std::ostream& operator <<(std::ostream& os,
const udp_client& uc) noexcept {
return os << uc.
to_string();}
118 bool operator==(
const udp_client& s)
const {
return data_ ==
s.data_;};
119 bool operator!=(
const udp_client& s)
const {
return !operator==(s);};
428 size_t send(const std::vector<byte_t>& dgram,
size_t bytes, const
xtd::
ustring& hostname, uint16_t port);
450 size_t send(const std::vector<byte_t>& dgram,
size_t bytes);
466 std::shared_ptr<data> data_;
Represents the status of an asynchronous operation.
Definition: iasync_result.h:21
Identifies a network address. This is an abstract class.
Definition: end_point.h:24
Provides an Internet Protocol (IP) address.
Definition: ip_address.h:30
Represents a network endpoint as an IP address and a port number.
Definition: ip_end_point.h:20
Implements the Berkeley sockets interface.
Definition: socket.h:63
Provides User Datagram Protocol (UDP) network services.
Definition: udp_client.h:35
void connect(const xtd::net::ip_end_point &end_point)
Establishes a default remote host using the specified network endpoint.
bool exclusive_address_use() const
Gets a boolean value that specifies whether the xtd::net::sockets::udp_client allows only one client ...
bool enable_broadcast() const
Gets a boolean value that specifies whether the xtd::net::sockets::udp_client may send or receive bro...
udp_client(uint16_t port, xtd::net::sockets::address_family addressFamily)
Initializes a new instance of the xtd::net::sockets::udp_client class and binds it to the local port ...
std::shared_ptr< xtd::iasync_result > begin_receive(xtd::async_callback callback, const std::any &state)
xtd::net::sockets::udp_client::receives a datagram from a remote host asynchronously.
size_t end_send(std::shared_ptr< xtd::iasync_result > async_result)
Ends a pending asynchronous send.
udp_client(const xtd::net::ip_end_point &local_end_point)
Initializes a new instance of the xtd::net::sockets::udp_client class and binds it to the specified l...
void close()
Closes the UDP connection.
bool active() const noexcept
Gets a value that indicates whether a connection has been made.
size_t send(const std::vector< byte_t > &dgram, size_t bytes, const xtd::ustring &hostname, uint16_t port)
xtd::net::sockets::udp_client::sends a UDP datagram to a specified port on a specified remote host.
bool dont_fragment() const
Gets a boolean value that specifies whether the xtd::net::sockets::udp_client allows Internet Protoco...
byte_t ttl() const
Gets a value that specifies the Time to Live (TTL) value of Internet Protocol (IP) packets sent by th...
std::vector< byte_t > end_receive(std::shared_ptr< xtd::iasync_result > async_result, xtd::net::ip_end_point &remote_end_point)
Ends a pending asynchronous receive.
void drop_multicast_group(const xtd::net::ip_address &multicast_address)
Leaves a multicast group.
udp_client(const xtd::ustring &hostname, uint16_t port)
Initializes a new instance of the xtd::net::sockets::udp_client class and establishes a default remot...
xtd::net::sockets::socket client() const noexcept
Gets the underlying network xtd::net::sockets::socket.
udp_client()
Initializes a new instance of the xtd::net::sockets::udp_client class.
void join_multicast_group(const xtd::net::ip_address &multicast_address)
Adds a xtd::net::sockets::udp_client to a multicast group.
bool multicast_loopback() const
Gets a boolean value that specifies whether outgoing multicast packets are delivered to the sending a...
void allow_nat_traversal(bool allowed)
Enables or disables Network Address Translation (NAT) traversal on a xtd::net::sockets::udp_client in...
size_t available() const
Gets the amount of data received from the network that is available to read.
std::vector< byte_t > receive(xtd::net::ip_end_point &remote_end_point)
Returns a UDP datagram that was sent by a remote host.
udp_client(xtd::net::sockets::address_family address_Family)
Initializes a new instance of the xtd::net::sockets::udp_client class.
std::shared_ptr< xtd::iasync_result > begin_send(const std::vector< byte_t > &dgram, size_t bytes, const xtd::ustring &hostname, uint16_t port, xtd::async_callback callback, const std::any &state)
xtd::net::sockets::udp_client::sends a datagram to a destination asynchronously. The destination is s...
udp_client(uint16_t port)
Initializes a new instance of the xtd::net::sockets::udp_client class and binds it to the local port ...
Supports all classes in the xtd class hierarchy and provides low-level services to derived classes....
Definition: object.h:26
virtual xtd::ustring to_string() const noexcept
Returns a std::string that represents the current object.
Represents text as a sequence of UTF-8 code units.
Definition: ustring.h:48
socket_error
Defines error codes for the xtd::net::sockets::socket class.
Definition: socket_error.h:24
address_family
Specifies the addressing scheme that an instance of the xtd::net::sockets::socket class can use.
Definition: address_family.h:24
delegate< void(std::shared_ptr< xtd::iasync_result > ar)> async_callback
References a method to be called when a corresponding asynchronous operation completes.
Definition: async_callback.h:18
@ success
Operation successful.
The xtd namespace contains all fundamental classes to access Hardware, Os, System,...
Definition: system_report.h:17
Contains xtd::net::sockets::socket class.