xtd 0.2.0
Loading...
Searching...
No Matches
socket.h
Go to the documentation of this file.
1
4#pragma once
5#include "address_family.h"
6#include "io_control_code.h"
9#include "linger_option.h"
10#include "multicast_option.h"
12#include "protocol_type.h"
13#include "select_mode.h"
14#include "socket_error.h"
15#include "socket_flags.h"
16#include "socket_information.h"
17#include "socket_option_level.h"
18#include "socket_option_name.h"
19#include "socket_shutdown.h"
20#include "socket_type.h"
21#include "../end_point.h"
22#include "../ip_address.h"
23#include "../../threading/manual_reset_event.h"
24#include "../../core_export.h"
25#include "../../argument_exception.h"
26#include "../../async_callback.h"
27#include "../../iasync_result.h"
28#include "../../iequatable.h"
29#include "../../not_implemented_exception.h"
30#include "../../not_supported_exception.h"
31#include "../../object.h"
32#include "../../types.h"
33#include "../../string.h"
34#include <exception>
35#include <memory>
36
38namespace xtd {
40 namespace net {
42 namespace sockets {
44 class socket_async_event_args;
46
74 class core_export_ socket : public xtd::object, public xtd::iequatable<socket> {
76 class async_result_socket : public xtd::object, public xtd::iasync_result {
77 public:
78 explicit async_result_socket(std::any async_state) : async_state_(async_state) {}
79 std::any async_state() const noexcept override {return async_state_;}
80 xtd::threading::wait_handle& async_wait_handle() noexcept override {return async_event_;}
81 bool completed_synchronously() const noexcept override {return false;}
82 bool is_completed() const noexcept override {return is_completed_;};
83
84 std::any async_state_;
85 bool is_completed_ = false;
88 std::exception_ptr exception_;
89 };
90
92 class async_result_accept : public async_result_socket {
93 public:
94 explicit async_result_accept(std::any async_state) : async_result_socket(async_state) {}
95 std::any socket_;
96 };
97
99 class async_result_connect : public async_result_socket {
100 public:
101 explicit async_result_connect(std::any async_state) : async_result_socket(async_state) {}
102 };
103
105 class async_result_disconnect : public async_result_socket {
106 public:
107 explicit async_result_disconnect(std::any async_state) : async_result_socket(async_state) {}
108 };
109
111 class async_result_receive : public async_result_socket {
112 public:
113 explicit async_result_receive(std::any async_state) : async_result_socket(async_state) {}
114 size_t number_of_bytes_received_ = 0;
115 };
116
118 class async_result_receive_from : public async_result_socket {
119 public:
120 explicit async_result_receive_from(std::any async_state) : async_result_socket(async_state) {}
122 size_t number_of_bytes_received_ = 0;
123 };
124
126 class async_result_receive_message_from : public async_result_socket {
127 public:
128 explicit async_result_receive_message_from(std::any async_state) : async_result_socket(async_state) {}
131 size_t number_of_bytes_received_ = 0;
132 xtd::net::sockets::ip_packet_information ip_packet_information_;
133 };
134
136 class async_result_send : public async_result_socket {
137 public:
138 explicit async_result_send(std::any async_state) : async_result_socket(async_state) {}
139 size_t number_of_bytes_sent_ = 0;
140 };
141
143 class async_result_send_to : public async_result_socket {
144 public:
145 explicit async_result_send_to(std::any async_state) : async_result_socket(async_state) {}
146 size_t number_of_bytes_sent_ = 0;
147 };
148
149 struct data;
150
151 public:
153
157
162 explicit socket(intptr handle);
183
185 socket(socket&&) = default;
186 socket(const socket&) = default;
187 ~socket();
188 socket& operator =(const socket&) = default;
190
192
198
203 size_t available() const;
204
212 bool blocking() const;
221 socket& blocking(bool value);
222
228 bool connected() const noexcept;
229
236 bool dont_fragment() const;
244 socket& dont_fragment(bool value);
245
252 bool dual_mode() const;
260 socket& dual_mode(bool value);
261
269 bool enable_broadcast() const;
278 socket& enable_broadcast(bool value);
279
288 bool exclusive_address_use() const;
299 socket& exclusive_address_use(bool value);
300
303 intptr handle() const noexcept;
304
308 bool is_bound() const noexcept;
309
327 xtd::net::sockets::linger_option linger_state() const;
346 socket& linger_state(const xtd::net::sockets::linger_option& value);
347
353 xtd::sptr<xtd::net::end_point> local_end_point() const;
354
363 bool multicast_loopback() const;
373 socket& multicast_loopback(bool value);
374
383 bool no_delay() const;
393 socket& no_delay(bool value);
394
398 xtd::net::sockets::protocol_type protocol_type() const noexcept;
399
406 size_t receive_buffer_size() const;
414 socket& receive_buffer_size(size_t value);
415
422 int32 receive_timeout() const;
431 socket& receive_timeout(int32 value);
432
438 xtd::sptr<xtd::net::end_point> remote_end_point() const;
439
446 size_t send_buffer_size() const;
454 socket& send_buffer_size(size_t value);
455
462 int32 send_timeout() const;
471 socket& send_timeout(int32 value);
472
476 xtd::net::sockets::socket_type socket_type() const noexcept;
477
487 xtd::byte ttl() const;
498 socket& ttl(xtd::byte value);
500
502
507 static bool os_supports_ip_v4() noexcept;
508
512 static bool os_supports_ip_v6() noexcept;
514
516
528 socket accept();
529
547 bool accept_async(xtd::net::sockets::socket_async_event_args& e);
548
563 xtd::sptr<xtd::iasync_result> begin_accept(xtd::async_callback callback, const std::any& state);
564
580 template<typename end_point_t>
581 xtd::sptr<xtd::iasync_result> begin_connect(const end_point_t& remote_end_point, xtd::async_callback callback, const std::any& state) {
582 return begin_connect_(xtd::new_sptr<end_point_t>(remote_end_point), callback, state);
583 }
597 xtd::sptr<xtd::iasync_result> begin_connect(const xtd::net::ip_address& address, uint16 port, xtd::async_callback callback, const std::any& state);
611 xtd::sptr<xtd::iasync_result> begin_connect(const std::vector<xtd::net::ip_address>& addresses, uint16 port, xtd::async_callback callback, const std::any& state);
625 xtd::sptr<xtd::iasync_result> begin_connect(const xtd::string& host, uint16 port, xtd::async_callback callback, const std::any& state);
626
637 xtd::sptr<xtd::iasync_result> begin_disconnect(bool reuse_socket, xtd::async_callback callback, const std::any& state);
638
656 xtd::sptr<xtd::iasync_result> begin_receive(std::vector<xtd::byte>& buffer, size_t offset, size_t size, xtd::net::sockets::socket_flags socket_flags, xtd::async_callback callback, const std::any& state);
675 xtd::sptr<xtd::iasync_result> begin_receive(std::vector<xtd::byte>& buffer, size_t offset, size_t size, xtd::net::sockets::socket_flags socket_flags, xtd::net::sockets::socket_error& error_code, xtd::async_callback callback, const std::any& state);
676
699 xtd::sptr<xtd::iasync_result> begin_receive_from(std::vector<xtd::byte>& buffer, size_t offset, size_t size, xtd::net::sockets::socket_flags socket_flags, xtd::net::end_point& remote_end_point, xtd::async_callback callback, const std::any& state);
700
718 xtd::sptr<xtd::iasync_result> begin_receive_message_from(std::vector<xtd::byte>& buffer, size_t offset, size_t size, xtd::net::sockets::socket_flags socket_flags, xtd::net::end_point& remote_end_point, xtd::async_callback callback, const std::any& state);
719
740 xtd::sptr<xtd::iasync_result> begin_send(const std::vector<xtd::byte>& buffer, size_t offset, size_t size, xtd::net::sockets::socket_flags socket_flags, xtd::async_callback callback, const std::any& state);
762 xtd::sptr<xtd::iasync_result> begin_send(const std::vector<xtd::byte>& buffer, size_t offset, size_t size, xtd::net::sockets::socket_flags socket_flags, xtd::net::sockets::socket_error& error_code, xtd::async_callback callback, const std::any& state);
763
784 xtd::sptr<xtd::iasync_result> begin_send_to(const std::vector<xtd::byte>& buffer, size_t offset, size_t size, xtd::net::sockets::socket_flags socket_flags, const xtd::net::end_point& remote_end_point, xtd::async_callback callback, const std::any& state);
785
797 template<typename end_point_t>
798 void bind(const end_point_t& local_end_point) {
799 bind_(xtd::new_sptr<end_point_t>(local_end_point));
800 }
801
807 void close();
808
818 template<typename end_point_t>
819 void connect(const end_point_t& remote_end_point) {
820 connect_(xtd::new_sptr<end_point_t>(remote_end_point));
821 }
822
833 void connect(const xtd::net::ip_address& address, uint16 port);
834
846 void connect(const std::vector<xtd::net::ip_address>& addresses, uint16 port);
847
858 void connect(const xtd::string& host, uint16 port);
859
868 void disconnect(bool reuse_socket);
869
880
891
900
931
944
959
991
1004
1005 using object::equals;
1006 bool equals(const socket& s) const noexcept override;
1007
1016 size_t get_raw_socket_option(int32 socket_option_level, int32 socket_option_name, intptr option_value, size_t size_option_value) const;
1017
1051
1059 size_t io_control(int32 io_control_code, std::vector<xtd::byte>& option_in_value, std::vector<xtd::byte>& option_out_value);
1067 size_t io_control(xtd::net::sockets::io_control_code io_control_code, std::vector<xtd::byte>& option_in_value, std::vector<xtd::byte>& option_out_value);
1068
1077 void listen(size_t backlog);
1078
1087 void listen();
1088
1102 bool poll(int32 micro_seconds, xtd::net::sockets::select_mode mode);
1103
1116 size_t receive(std::vector<xtd::byte>& buffer);
1117
1131 size_t receive(std::vector<xtd::byte>& buffer, xtd::net::sockets::socket_flags socket_flags);
1132
1148 size_t receive(std::vector<xtd::byte>& buffer, size_t size, xtd::net::sockets::socket_flags socket_flags);
1149
1165 size_t receive(std::vector<xtd::byte>& buffer, size_t offset, size_t size, xtd::net::sockets::socket_flags socket_flags);
1166
1182 size_t receive(std::vector<xtd::byte>& buffer, size_t offset, size_t size, xtd::net::sockets::socket_flags socket_flags, xtd::net::sockets::socket_error& error);
1183
1199 size_t receive_from(std::vector<xtd::byte>& buffer, xtd::net::end_point& remote_end_point);
1200
1217 size_t receive_from(std::vector<xtd::byte>& buffer, xtd::net::sockets::socket_flags socket_flags, xtd::net::end_point& remote_end_point);
1218
1237 size_t receive_from(std::vector<xtd::byte>& buffer, size_t size, xtd::net::sockets::socket_flags socket_flags, xtd::net::end_point& remote_end_point);
1238
1257 size_t receive_from(std::vector<xtd::byte>& buffer, size_t offset, size_t size, xtd::net::sockets::socket_flags socket_flags, xtd::net::end_point& remote_end_point);
1258
1260
1273 size_t send(const std::vector<xtd::byte>& buffer);
1274
1288 size_t send(const std::vector<xtd::byte>& buffer, xtd::net::sockets::socket_flags socket_flags);
1289
1305 size_t send(const std::vector<xtd::byte>& buffer, size_t size, xtd::net::sockets::socket_flags socket_flags);
1306
1323 size_t send(const std::vector<xtd::byte>& buffer, size_t offset, size_t size, xtd::net::sockets::socket_flags socket_flags);
1324
1340 size_t send(const std::vector<xtd::byte>& buffer, size_t offset, size_t size, xtd::net::sockets::socket_flags socket_flags, xtd::net::sockets::socket_error& error_code);
1341
1354 size_t send_to(const std::vector<xtd::byte>& buffer, const xtd::net::end_point& remote_end_point);
1368 size_t send_to(const std::vector<xtd::byte>& buffer, xtd::net::sockets::socket_flags socket_flags, const xtd::net::end_point& remote_end_point);
1384 size_t send_to(const std::vector<xtd::byte>& buffer, size_t size, xtd::net::sockets::socket_flags socket_flags, const xtd::net::end_point& remote_end_point);
1401 size_t send_to(const std::vector<xtd::byte>& buffer, size_t offset, size_t size, xtd::net::sockets::socket_flags socket_flags, const xtd::net::end_point& remote_end_point);
1402
1415
1446
1508
1519 void set_raw_socket_option(int32 socket_option_level, int32 socket_option_name, intptr option_value, size_t option_value_size);
1520
1542
1544
1561 static size_t select(std::vector<socket>& check_read, std::vector<socket>& check_write, std::vector<socket>& check_error, int32 microseconds);
1563
1564 private:
1565 static xtd::net::sockets::socket_error get_last_error_();
1566 xtd::sptr<xtd::iasync_result> begin_connect_(xtd::sptr<xtd::net::end_point> remote_end_point, xtd::async_callback callback, const std::any& state);
1567 void bind_(xtd::sptr<xtd::net::end_point> local_end_point);
1568 void connect_(xtd::sptr<xtd::net::end_point> remote_end_point);
1569
1570 xtd::sptr<data> data_;
1571 };
1572 }
1573 }
1574}
Contains xtd::net::sockets::address_family enum.
Represents text as a sequence of character units.
Definition basic_string.h:79
Represents the status of an asynchronous operation.
Definition iasync_result.h:25
Defines a generalized method that a value type or class implements to create a type-specific method f...
Definition iequatable.h:22
Identifies a network address. This is an abstract class.
Definition end_point.h:27
Provides an Internet Protocol (IP) address.
Definition ip_address.h:37
Gets the network interface information that is associated with a call to xtd::net::sockets::socket::r...
Definition ip_packet_information.h:36
Contains option values for joining an IPv6 multicast group.
Definition ip_v6_multicast_option.h:32
Specifies whether a xtd::net::sockets::socket will remain connected after a call to the xtd::net::soc...
Definition linger_option.h:34
Contains IPAddress values used to join and drop multicast groups.
Definition multicast_option.h:39
Represents an asynchronous socket operation.
Definition socket_async_event_args.h:54
Encapsulates the information that is necessary to duplicate a xtd::net::sockets::socket.
Definition socket_information.h:33
Implements the Berkeley sockets interface.
Definition socket.h:74
void set_raw_socket_option(int32 socket_option_level, int32 socket_option_name, intptr option_value, size_t option_value_size)
Sets a socket option value using platform-specific level and name identifiers.
socket(intptr handle)
Initializes a new instance of the xtd::net::sockets::socket class for the specified socket handle.
void connect(const std::vector< xtd::net::ip_address > &addresses, uint16 port)
Establishes a connection to a remote host. The host is specified by an array of IP addresses and a po...
void bind(const end_point_t &local_end_point)
Associates a xtd::net::sockets::socket with a local endpoint.
Definition socket.h:798
xtd::net::sockets::ip_v6_multicast_option get_socket_ip_v6_multicast_option(xtd::net::sockets::socket_option_name socket_option_name) const
Returns the multicast xtd::net::sockets::socket option, represented as xtd::net::sockets::ip_v6_multi...
size_t send(const std::vector< xtd::byte > &buffer)
Sends data to a connected xtd::net::sockets::socket.
void set_socket_option(xtd::net::sockets::socket_option_name socket_option_name, const xtd::net::sockets::multicast_option &option_value)
Sets the linger xtd::net::sockets::socket option to the specified integer value.
size_t send(const std::vector< xtd::byte > &buffer, xtd::net::sockets::socket_flags socket_flags)
Sends data to a connected xtd::net::sockets::socket using the specified xtd::net::sockets::socket_fla...
xtd::net::sockets::multicast_option get_socket_multicast_option(xtd::net::sockets::socket_option_name socket_option_name) const
Returns the multicast xtd::net::sockets::socket option, represented as xtd::net::sockets::multicast_o...
size_t receive(std::vector< xtd::byte > &buffer, size_t offset, size_t size, xtd::net::sockets::socket_flags socket_flags, xtd::net::sockets::socket_error &error)
Receives the specified number of bytes from a bound xtd::net::sockets::socket into the specified offs...
socket(xtd::net::sockets::address_family address_family, xtd::net::sockets::socket_type socket_type, xtd::net::sockets::protocol_type protocol_type)
Initializes a new instance of the xtd::net::sockets::socket class using the specified address family,...
size_t io_control(int32 io_control_code, std::vector< xtd::byte > &option_in_value, std::vector< xtd::byte > &option_out_value)
Sets low-level operating modes for the xtd::net::sockets::socket using numerical control codes.
size_t end_send_to(xtd::sptr< xtd::iasync_result > async_result)
Ends a pending asynchronous send to a specific location.
size_t receive_from(std::vector< xtd::byte > &buffer, size_t size, xtd::net::sockets::socket_flags socket_flags, xtd::net::end_point &remote_end_point)
Receives data from a bound xtd::net::sockets::socket into a receive buffer.
size_t receive(std::vector< xtd::byte > &buffer, size_t offset, size_t size, xtd::net::sockets::socket_flags socket_flags)
Receives the specified number of bytes from a bound xtd::net::sockets::socket into the specified offs...
xtd::sptr< xtd::iasync_result > begin_send_to(const std::vector< xtd::byte > &buffer, size_t offset, size_t size, xtd::net::sockets::socket_flags socket_flags, const xtd::net::end_point &remote_end_point, xtd::async_callback callback, const std::any &state)
Sends data asynchronously to a specific remote host.
int32 get_socket_option(xtd::net::sockets::socket_option_level socket_option_level, xtd::net::sockets::socket_option_name socket_option_name) const
Returns the value of a specified xtd::net::sockets::socket option, represented as integer.
bool poll(int32 micro_seconds, xtd::net::sockets::select_mode mode)
Determines the status of the xtd::net::sockets::socket.
size_t end_send(xtd::sptr< xtd::iasync_result > async_result, xtd::net::sockets::socket_error &error_code)
Ends a pending asynchronous send.
static size_t select(std::vector< socket > &check_read, std::vector< socket > &check_write, std::vector< socket > &check_error, int32 microseconds)
Determines the status of one or more sockets.
xtd::sptr< xtd::iasync_result > begin_send(const std::vector< xtd::byte > &buffer, size_t offset, size_t size, xtd::net::sockets::socket_flags socket_flags, xtd::net::sockets::socket_error &error_code, xtd::async_callback callback, const std::any &state)
Sends data asynchronously to a connected xtd::net::sockets::socket::socket.
void end_connect(xtd::sptr< xtd::iasync_result > async_result)
Ends a pending asynchronous connection request.
xtd::sptr< xtd::iasync_result > begin_connect(const std::vector< xtd::net::ip_address > &addresses, uint16 port, xtd::async_callback callback, const std::any &state)
Begins an asynchronous request for a remote host connection. The host is specified by an xtd::net::ip...
xtd::sptr< xtd::iasync_result > begin_receive(std::vector< xtd::byte > &buffer, size_t offset, size_t size, xtd::net::sockets::socket_flags socket_flags, xtd::net::sockets::socket_error &error_code, xtd::async_callback callback, const std::any &state)
Begins to asynchronously receive data from a connected xtd::net::sockets::socket::socket.
size_t send(const std::vector< xtd::byte > &buffer, size_t size, xtd::net::sockets::socket_flags socket_flags)
Sends the specified number of bytes of data to a connected xtd::net::sockets::socket,...
void listen(size_t backlog)
Places a xtd::net::sockets::socket in a listening state.
xtd::sptr< xtd::iasync_result > begin_send(const std::vector< xtd::byte > &buffer, size_t offset, size_t size, xtd::net::sockets::socket_flags socket_flags, xtd::async_callback callback, const std::any &state)
Sends data asynchronously to a connected xtd::net::sockets::socket::socket.
void set_socket_option(xtd::net::sockets::socket_option_level socket_option_level, xtd::net::sockets::socket_option_name socket_option_name, bool option_value)
Sets the specified xtd::net::sockets::socket option to the specified integer value.
size_t receive(std::vector< xtd::byte > &buffer)
Receives data from a bound xtd::net::sockets::socket into a receive buffer.
void end_disconnect(xtd::sptr< xtd::iasync_result > async_result)
Ends a pending asynchronous disconnect request.
xtd::sptr< xtd::iasync_result > begin_connect(const xtd::net::ip_address &address, uint16 port, xtd::async_callback callback, const std::any &state)
Begins an asynchronous request for a remote host connection. The host is specified by an xtd::net::ip...
void connect(const xtd::string &host, uint16 port)
Establishes a connection to a remote host. The host is specified by a host name and a port number.
size_t receive(std::vector< xtd::byte > &buffer, size_t size, xtd::net::sockets::socket_flags socket_flags)
Receives the specified number of bytes of data from a bound xtd::net::sockets::socket into a receive ...
size_t send_to(const std::vector< xtd::byte > &buffer, size_t size, xtd::net::sockets::socket_flags socket_flags, const xtd::net::end_point &remote_end_point)
Sends the specified number of bytes of data to the specified endpoint using the specified xtd::net::s...
xtd::net::sockets::address_family address_family() const noexcept
Gets the address family of the xtd::net::sockets::socket.
void shutdown(xtd::net::sockets::socket_shutdown how)
Disables sends and receives on a xtd::net::sockets::socket.
xtd::sptr< xtd::iasync_result > begin_disconnect(bool reuse_socket, xtd::async_callback callback, const std::any &state)
Begins an asynchronous request to disconnect from a remote endpoint.
size_t send_to(const std::vector< xtd::byte > &buffer, xtd::net::sockets::socket_flags socket_flags, const xtd::net::end_point &remote_end_point)
Sends data to a specific endpoint using the specified xtd::net::sockets::socket_flags.
void set_socket_option(xtd::net::sockets::socket_option_name socket_option_name, const xtd::net::sockets::ip_v6_multicast_option &option_value)
Sets the linger xtd::net::sockets::socket option to the specified integer value.
void connect(const xtd::net::ip_address &address, uint16 port)
Establishes a connection to a remote host. The host is specified by an IP address and a port number.
void set_socket_option(xtd::net::sockets::socket_option_level socket_option_level, xtd::net::sockets::socket_option_name socket_option_name, int32 option_value)
Sets the specified xtd::net::sockets::socket option to the specified integer value.
xtd::sptr< xtd::iasync_result > begin_connect(const xtd::string &host, uint16 port, xtd::async_callback callback, const std::any &state)
Begins an asynchronous request for a remote host connection. The host is specified by a host name and...
size_t receive_from(std::vector< xtd::byte > &buffer, size_t offset, size_t size, xtd::net::sockets::socket_flags socket_flags, xtd::net::end_point &remote_end_point)
Receives data from a bound xtd::net::sockets::socket into a receive buffer.
void close()
Closes the xtd::net::sockets::socket connection and releases all associated resources.
void connect(const end_point_t &remote_end_point)
Establishes a connection to a remote host.
Definition socket.h:819
xtd::net::sockets::linger_option get_socket_linger_option() const
Returns the linger xtd::net::sockets::socket option, represented as xtd::net::sockets::linger_option.
size_t end_receive_message_from(xtd::sptr< xtd::iasync_result > async_result, xtd::net::sockets::socket_flags &socket_flags, xtd::sptr< xtd::net::end_point > &end_point, xtd::net::sockets::ip_packet_information &ip_packet_information)
Ends a pending asynchronous read from a specific endpoint. This method also reveals more information ...
void disconnect(bool reuse_socket)
Closes the socket connection and allows reuse of the socket.
void set_socket_option(xtd::net::sockets::linger_option option_value)
Sets the linger xtd::net::sockets::socket option to the specified integer value.
socket(const xtd::net::sockets::socket_information &socket_information)
Initializes a new instance of the xtd::net::sockets::socket class using the specified value returned ...
size_t io_control(xtd::net::sockets::io_control_code io_control_code, std::vector< xtd::byte > &option_in_value, std::vector< xtd::byte > &option_out_value)
Sets low-level operating modes for the xtd::net::sockets::socket using xtd::net::sockets::io_control_...
xtd::sptr< xtd::iasync_result > begin_receive(std::vector< xtd::byte > &buffer, size_t offset, size_t size, xtd::net::sockets::socket_flags socket_flags, xtd::async_callback callback, const std::any &state)
Begins to asynchronously receive data from a connected xtd::net::sockets::socket::socket.
size_t send(const std::vector< xtd::byte > &buffer, size_t offset, size_t size, xtd::net::sockets::socket_flags socket_flags, xtd::net::sockets::socket_error &error_code)
Sends the specified number of bytes of data to a connected xtd::net::sockets::socket,...
socket end_accept(xtd::sptr< xtd::iasync_result > async_result)
Asynchronously accepts an incoming connection attempt and creates a new xtd::net::sockets::socket::so...
size_t get_raw_socket_option(int32 socket_option_level, int32 socket_option_name, intptr option_value, size_t size_option_value) const
Gets a socket option value using platform-specific level and name identifiers.
size_t send(const std::vector< xtd::byte > &buffer, size_t offset, size_t size, xtd::net::sockets::socket_flags socket_flags)
Sends the specified number of bytes of data to a connected xtd::net::sockets::socket,...
size_t receive_from(std::vector< xtd::byte > &buffer, xtd::net::end_point &remote_end_point)
Receives data from a bound xtd::net::sockets::socket into a receive buffer.
socket()
Initializes a new instance of the xtd::net::sockets::socket class.
xtd::sptr< xtd::iasync_result > begin_receive_from(std::vector< xtd::byte > &buffer, size_t offset, size_t size, xtd::net::sockets::socket_flags socket_flags, xtd::net::end_point &remote_end_point, xtd::async_callback callback, const std::any &state)
Begins to asynchronously receive data from a specified network device.
size_t end_send(xtd::sptr< xtd::iasync_result > async_result)
Ends a pending asynchronous send.
xtd::sptr< xtd::iasync_result > begin_receive_message_from(std::vector< xtd::byte > &buffer, size_t offset, size_t size, xtd::net::sockets::socket_flags socket_flags, xtd::net::end_point &remote_end_point, xtd::async_callback callback, const std::any &state)
Begins to asynchronously receive the specified number of bytes of data into the specified location of...
size_t receive(std::vector< xtd::byte > &buffer, xtd::net::sockets::socket_flags socket_flags)
Receives data from a bound xtd::net::sockets::socket into a receive buffer, using the specified xtd::...
void listen()
Places a xtd::net::sockets::socket in a listening state.
size_t end_receive(xtd::sptr< xtd::iasync_result > async_result, xtd::net::sockets::socket_error &error_code)
Ends a pending asynchronous read.
size_t send_to(const std::vector< xtd::byte > &buffer, size_t offset, size_t size, xtd::net::sockets::socket_flags socket_flags, const xtd::net::end_point &remote_end_point)
Sends the specified number of bytes of data to the specified endpoint, starting at the specified loca...
size_t end_receive_from(xtd::sptr< xtd::iasync_result > async_result, xtd::sptr< xtd::net::end_point > &end_point)
Ends a pending asynchronous read from a specific endpoint.
size_t receive_from(std::vector< xtd::byte > &buffer, xtd::net::sockets::socket_flags socket_flags, xtd::net::end_point &remote_end_point)
Receives data from a bound xtd::net::sockets::socket into a receive buffer.
void set_ip_protection_level(xtd::net::sockets::ip_protection_level level)
Sets the IP protection level on a socket.
socket(xtd::net::sockets::socket_type socket_type, xtd::net::sockets::protocol_type protocol_type)
Initializes a new instance of the xtd::net::sockets::socket class using the specified socket type and...
size_t send_to(const std::vector< xtd::byte > &buffer, const xtd::net::end_point &remote_end_point)
Sends data to the specified endpoint.
size_t end_receive(xtd::sptr< xtd::iasync_result > async_result)
Ends a pending asynchronous read.
Supports all classes in the xtd class hierarchy and provides low-level services to derived classes....
Definition object.h:42
Represents a thread synchronization event that, when signaled, must be reset manually....
Definition manual_reset_event.h:35
Encapsulates operating system specific objects that wait for exclusive access to shared resources.
Definition wait_handle.h:52
#define core_export_
Define shared library export.
Definition core_export.h:13
int32_t int32
Represents a 32-bit signed integer.
Definition int32.h:23
size_t size
Represents a size of any object in bytes.
Definition size.h:23
intmax_t intptr
Represent a pointer or a handle.
Definition intptr.h:23
std::shared_ptr< type_t > sptr
The xtd::sptr object is a shared pointer.
Definition sptr.h:25
uint16_t uint16
Represents a 16-bit unsigned integer.
Definition uint16.h:23
socket_error
Defines error codes for the xtd::net::sockets::socket class.
Definition socket_error.h:30
xtd::sptr< xtd::iasync_result > async_result
Represents the status of an asynchronous operation.
Definition async_result.h:19
delegate< void(async_result ar)> async_callback
References a method to be called when a corresponding asynchronous operation completes.
Definition delegate.h:36
address_family
Specifies the addressing scheme that an instance of the xtd::net::sockets::socket class can use.
Definition address_family.h:30
socket_option_level
Defines socket option levels for the xtd::net::sockets::socket::set_socket_option and xtd::net::socke...
Definition socket_option_level.h:31
socket_option_name
Defines configuration option names.
Definition socket_option_name.h:31
ip_protection_level
A value that enables restriction of an IPv6 socket to a specified scope, such as addresses with the s...
Definition ip_protection_level.h:31
protocol_type
Specifies the protocols that the xtd::net::sockets::socket class supports.
Definition protocol_type.h:30
socket_flags
Specifies socket send and receive behaviors. This enumeration has a flags attribute that allows a bit...
Definition socket_flags.h:30
select_mode
Defines the polling modes for the xtd::net::sockets::socket::poll method.
Definition select_mode.h:31
socket_type
Specifies the type of socket that an instance of the xtd::net::sockets::socket class represents.
Definition socket_type.h:32
socket_shutdown
Defines constants that are used by the xtd::net::sockets::socket::shutdown method.
Definition socket_shutdown.h:31
io_control_code
Specifies the IO control codes supported by the xtd::net::sockets::socket::io_control method.
Definition io_control_code.h:30
@ success
Operation successful.
@ receive_message_from
A socket receive_message_from operation.
@ none
Use no flags for this call.
Contains xtd::net::sockets::io_control_code enum.
Contains xtd::net::sockets::ip_packet_information class.
Contains xtd::net::sockets::ip_protection_level enum.
Contains xtd::net::sockets::ip_v6_multicast_option class.
Contains xtd::net::sockets::linger_option class.
Contains xtd::net::sockets::multicast_option class.
The xtd namespace contains all fundamental classes to access Hardware, Os, System,...
Definition xtd_about_box.h:10
Contains xtd::net::sockets::protocol_type enum.
Contains xtd::net::sockets::select_mode enum.
Contains xtd::net::sockets::socket_error enum.
Contains xtd::net::sockets::socket_flags enum.
Contains xtd::net::sockets::socket_information class.
Contains xtd::net::sockets::socket_option_level enum.
Contains xtd::net::sockets::socket_option_name enum.
Contains xtd::net::sockets::socket_shutdown enum.
Contains xtd::net::sockets::socket_type enum.