6 #include "../../object.h" 7 #include "../../ustring.h" 8 #include "../ip_end_point.h" 43 explicit async_result_socket(
std::any async_state) : async_state_(async_state) {}
44 std::any async_state()
const noexcept
override {
return async_state_;}
45 std::shared_mutex& async_mutex()
override {
return async_mutex_;}
46 bool completed_synchronously()
const noexcept
override {
return false;}
47 bool is_completed()
const noexcept
override {
return is_completed_;};
50 bool is_completed_ =
false;
51 std::shared_mutex async_mutex_;
53 std::exception_ptr exception_;
56 class async_result_receive :
public async_result_socket {
58 explicit async_result_receive(
std::any async_state) : async_result_socket(async_state) {}
59 std::vector<byte_t> buffer_;
63 class async_result_send :
public async_result_socket {
65 explicit async_result_send(
std::any async_state) : async_result_socket(async_state) {}
66 size_t number_of_bytes_sent_ = 0;
126 friend std::ostream& operator <<(std::ostream& os,
const udp_client& uc) noexcept {
return os << uc.
to_string();}
127 bool operator==(
const udp_client&
s)
const {
return data_ == s.data_;};
128 bool operator!=(
const udp_client& s)
const {
return !operator==(s);};
141 size_t available()
const;
175 bool enable_broadcast()
const;
246 void allow_nat_traversal(
bool allowed);
286 std::shared_ptr<xtd::iasync_result> begin_send(
const std::vector<byte_t>& dgram,
size_t bytes,
xtd::async_callback callback,
const std::any& state);
356 std::vector<byte_t> end_receive(std::shared_ptr<xtd::iasync_result> async_result,
xtd::net::ip_end_point& remote_end_point);
367 size_t end_send(std::shared_ptr<xtd::iasync_result> async_result);
443 size_t send(
const std::vector<byte_t>& dgram,
size_t bytes,
const xtd::ustring& hostname, uint16_t port);
465 size_t send(
const std::vector<byte_t>& dgram,
size_t bytes);
475 bool active()
const noexcept;
486 std::shared_ptr<data> data_;
Implements the Berkeley sockets interface.
Definition: socket.h:68
virtual xtd::ustring to_string() const noexcept
Returns a sxd::ustring that represents the current object.
Provides an Internet Protocol (IP) address.
Definition: ip_address.h:34
Represents the status of an asynchronous operation.
Definition: iasync_result.h:21
An IP multicast loopback.
Identifies a network address. This is an abstract class.
Definition: end_point.h:24
The xtd namespace contains all fundamental classes to access Hardware, Os, System, and more.
Definition: system_report.h:17
Enables a socket to be bound for exclusive access.
Represents a network endpoint as an IP address and a port number.
Definition: ip_end_point.h:20
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
Represents text as a sequence of UTF-8 code units.
Definition: ustring.h:50
socket_error
Defines error codes for the xtd::net::sockets::socket class.
Definition: socket_error.h:27
Do not fragment IP datagrams.
Supports datagrams, which are connectionless, unreliable messages of a fixed (typically small) maximu...
A socket connect operation.
Indicates that all styles except allow_binary_specifier, allow_octal_specifier and allow_hex_specifie...
A socket receive operation.
Supports all classes in the xtd class hierarchy and provides low-level services to derived classes...
Definition: object.h:30
Provides User Datagram Protocol (UDP) network services.
Definition: udp_client.h:40
Contains xtd::net::sockets::socket class.
address_family
Specifies the addressing scheme that an instance of the xtd::net::sockets::socket class can use...
Definition: address_family.h:27