xtd 0.2.0
socket_async_event_args.h
Go to the documentation of this file.
1 #pragma once
6 #include "socket.h"
7 #include "socket_flags.h"
9 #include "send_packets_element.h"
10 #include "transmit_file_options.h"
11 #include "../../any.h"
12 #include "../../delegate.h"
13 #include "../../event.h"
14 #include "../../event_args.h"
15 #include <memory>
16 #include <vector>
17 
19 #undef unix
20 
23 namespace xtd {
25  namespace net {
27  namespace sockets {
52  class core_export_ socket_async_event_args : public xtd::event_args {
53  public:
55 
65  socket_async_event_args() = default;
68  explicit socket_async_event_args(bool suppress_execution_context_flow);
70 
72 
77  xtd::net::sockets::socket accept_socket() const noexcept;
82  socket_async_event_args& accept_socket(const xtd::net::sockets::socket& value) noexcept;
83 
88  const std::vector<xtd::byte>& buffer() const noexcept;
93  std::vector<xtd::byte>& buffer() noexcept;
95 
97 
101  void set_buffer(const std::vector<xtd::byte>& memory_buffer);
102 
110  void set_buffer(size_t offset, size_t count);
118  void set_buffer(const std::vector<xtd::byte>& buffer, size_t offset, size_t count);
120 
122 
131 
132  protected:
134 
143  virtual void on_complete(const socket_async_event_args& e);
145 
146  private:
147  friend socket;
148  xtd::net::sockets::socket accept_socket_;
149  std::vector<xtd::byte> buffer_;
150  std::vector<std::vector<xtd::byte>> buffer_list_;
151  size_t bytes_transferred_ = 0;
152  std::unique_ptr<xtd::system_exception> connect_by_name_error_;
153  xtd::net::sockets::socket connect_socket_;
154  size_t count_ = 0;
155  bool disconnect_reuse_socket_ = false;
157  std::vector<xtd::byte> memory_buffer_;
158  size_t offset_ = 0;
159  xtd::net::sockets::ip_packet_information receive_message_from_packet_info_;
160  std::unique_ptr<xtd::net::end_point> remote_end_point_;
161  std::vector<xtd::net::sockets::send_packets_element> send_packets_elements_;
163  size_t send_packets_send_size_ = 0;
166  std::any user_token_;
167  };
168  }
169  }
170 }
Implements the Berkeley sockets interface.
Definition: socket.h:71
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:34
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:30
socket_error
Defines error codes for the xtd::net::sockets::socket class.
Definition: socket_error.h:28
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:129
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:30
socket_flags
Specifies socket send and receive behaviors. This enumeration has a flags attribute that allows a bit...
Definition: socket_flags.h:28
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:52
Contains xtd::net::sockets::ip_packet_information class.
Contains xtd::net::sockets::socket class.