xtd - Reference Guide  0.1.1
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
22 
24 namespace xtd {
26  namespace net {
28  namespace sockets {
47  public:
59  socket_async_event_args(bool suppress_execution_context_flow);
60 
69  socket_async_event_args& accept_socket(const xtd::net::sockets::socket& value) noexcept;
70 
75  const std::vector<byte_t>& buffer() const noexcept;
80  std::vector<byte_t>& buffer() noexcept;
81 
84  void set_buffer(const std::vector<byte_t>& memory_buffer);
85 
93  void set_buffer(size_t offset, size_t count);
101  void set_buffer(const std::vector<byte_t>& buffer, size_t count, size_t offset);
102 
108 
109  protected:
117  virtual void on_complete(const socket_async_event_args& e);
118 
119  private:
120  friend socket;
121  xtd::net::sockets::socket accept_socket_;
122  std::vector<byte_t> buffer_;
123  std::vector<std::vector<byte_t>> buffer_list_;
124  size_t bytes_transferred_ = 0;
125  std::unique_ptr<xtd::system_exception> connect_by_name_error_;
126  xtd::net::sockets::socket connect_socket_;
127  size_t count_ = 0;
128  bool disconnect_reuse_socket_ = false;
129  xtd::net::sockets::socket_async_operation last_operation = xtd::net::sockets::socket_async_operation::none;
130  std::vector<byte_t> memory_buffer_;
131  size_t offset_ = 0;
132  xtd::net::sockets::ip_packet_information receive_message_from_packet_info_;
133  std::unique_ptr<xtd::net::end_point> remote_end_point_;
134  std::vector<xtd::net::sockets::send_packets_element> send_packets_elements_;
135  xtd::net::sockets::transmit_file_options send_packets_flags_ = xtd::net::sockets::transmit_file_options::use_default_worker_thread;
136  size_t send_packets_send_size_ = 0;
137  xtd::net::sockets::socket_error socket_error_ = xtd::net::sockets::socket_error::success;
138  xtd::net::sockets::socket_flags socket_flags_ = xtd::net::sockets::socket_flags::none;
139  std::any user_token_;
140  };
141  }
142  }
143 }
Represents the base class for classes that contain event data, and provides a value to use for events...
Definition: event_args.h:18
Represents an event.
Definition: event.h:21
Identifies a network address. This is an abstract class.
Definition: end_point.h:24
Gets the network interface information that is associated with a call to xtd::net::sockets::socket::r...
Definition: ip_packet_information.h:28
Represents an element in a xtd::net::sockets::send_packets_element array.
Definition: send_packets_element.h:33
Represents an asynchronous socket operation.
Definition: socket_async_event_args.h:46
virtual void on_complete(const socket_async_event_args &e)
Represents a method that is called when an asynchronous operation completes.
socket_async_event_args(bool suppress_execution_context_flow)
Initializes the SocketAsyncEventArgs.
void set_buffer(const std::vector< byte_t > &memory_buffer)
Sets the region of memory to use as a buffer with an asynchronous socket method.
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:107
xtd::net::sockets::socket accept_socket() const noexcept
Gets the socket to use or the socket created for accepting a connection with an asynchronous socket m...
const std::vector< byte_t > & buffer() const noexcept
Gets the data buffer to use with an asynchronous socket method.
socket_async_event_args()=default
Creates an empty xtd::net::sockets::socket_async_event_args instance.
Implements the Berkeley sockets interface.
Definition: socket.h:63
Defines the base class for predefined exceptions in the xtd namespace.
Definition: system_exception.h:24
socket_error
Defines error codes for the xtd::net::sockets::socket class.
Definition: socket_error.h:24
transmit_file_options
The TransmitFileOptions enumeration defines values used in file transfer requests.
Definition: transmit_file_options.h:26
socket_async_operation
The type of asynchronous socket operation most recently performed with this context object.
Definition: socket_async_operation.h:26
socket_flags
Specifies socket send and receive behaviors. This enumeration has a flags attribute that allows a bit...
Definition: socket_flags.h:24
Contains xtd::net::sockets::ip_packet_information class.
The xtd namespace contains all fundamental classes to access Hardware, Os, System,...
Definition: system_report.h:17
Contains xtd::net::sockets::send_packets_element class.
Contains xtd::net::sockets::socket class.
Contains xtd::net::sockets::socket_async_operation enum.
Contains xtd::net::sockets::socket_flags enum.
Contains xtd::net::sockets::transmit_file_options enum.