xtd - Reference Guide  0.2.0
Modern c++17/20 framework to create console, GUI and unit test applications on Windows, macOS, Linux, iOS and android.
socket_async_event_args.h
Go to the documentation of this file.
1 #pragma once
5 
6 #include <any>
7 #include <memory>
8 #include <vector>
9 #include "../../delegate.h"
10 #include "../../event.h"
11 #include "../../event_args.h"
12 #include "ip_packet_information.h"
13 #include "socket.h"
14 #include "socket_flags.h"
15 #include "socket_async_operation.h"
16 #include "send_packets_element.h"
17 #include "transmit_file_options.h"
18 
20 #undef unix
21 
24 namespace xtd {
26  namespace net {
28  namespace sockets {
51  class core_export_ socket_async_event_args : public xtd::event_args {
52  public:
54 
64  socket_async_event_args() = default;
67  explicit socket_async_event_args(bool suppress_execution_context_flow);
69 
71 
76  xtd::net::sockets::socket accept_socket() const noexcept;
81  socket_async_event_args& accept_socket(const xtd::net::sockets::socket& value) noexcept;
82 
87  const std::vector<byte_t>& buffer() const noexcept;
92  std::vector<byte_t>& buffer() noexcept;
94 
96 
100  void set_buffer(const std::vector<byte_t>& memory_buffer);
101 
109  void set_buffer(size_t offset, size_t count);
117  void set_buffer(const std::vector<byte_t>& buffer, size_t offset, size_t count);
119 
121 
130 
131  protected:
133 
142  virtual void on_complete(const socket_async_event_args& e);
144 
145  private:
146  friend socket;
147  xtd::net::sockets::socket accept_socket_;
148  std::vector<byte_t> buffer_;
149  std::vector<std::vector<byte_t>> buffer_list_;
150  size_t bytes_transferred_ = 0;
151  std::unique_ptr<xtd::system_exception> connect_by_name_error_;
152  xtd::net::sockets::socket connect_socket_;
153  size_t count_ = 0;
154  bool disconnect_reuse_socket_ = false;
156  std::vector<byte_t> memory_buffer_;
157  size_t offset_ = 0;
158  xtd::net::sockets::ip_packet_information receive_message_from_packet_info_;
159  std::unique_ptr<xtd::net::end_point> remote_end_point_;
160  std::vector<xtd::net::sockets::send_packets_element> send_packets_elements_;
162  size_t send_packets_send_size_ = 0;
165  std::any user_token_;
166  };
167  }
168  }
169 }
Implements the Berkeley sockets interface.
Definition: socket.h:68
Use no flags for this call.
Represents the base class for classes that contain event data, and provides a value to use for events...
Definition: event_args.h:18
Contains xtd::net::sockets::socket_flags enum.
The xtd namespace contains all fundamental classes to access Hardware, Os, System, and more.
Definition: system_report.h:17
Gets the network interface information that is associated with a call to xtd::net::sockets::socket::r...
Definition: ip_packet_information.h:33
Contains xtd::net::sockets::send_packets_element class.
transmit_file_options
The TransmitFileOptions enumeration defines values used in file transfer requests.
Definition: transmit_file_options.h:29
socket_error
Defines error codes for the xtd::net::sockets::socket class.
Definition: socket_error.h:27
Represents an event.
Definition: event.h:21
xtd::event< socket_async_event_args, xtd::delegate< void(const socket_async_event_args &)> > completed
The event used to complete an asynchronous operation.
Definition: socket_async_event_args.h:128
Socket options apply to all sockets.
Use the default thread to process long file transfer requests.
Contains xtd::net::sockets::transmit_file_options enum.
socket_async_operation
The type of asynchronous socket operation most recently performed with this context object...
Definition: socket_async_operation.h:29
socket_flags
Specifies socket send and receive behaviors. This enumeration has a flags attribute that allows a bit...
Definition: socket_flags.h:27
Indicates that all styles except allow_binary_specifier, allow_octal_specifier and allow_hex_specifie...
Contains xtd::net::sockets::socket_async_operation enum.
Represents an asynchronous socket operation.
Definition: socket_async_event_args.h:51
Contains xtd::net::sockets::ip_packet_information class.
Contains xtd::net::sockets::socket class.