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 {
47  public:
56  socket_async_event_args() = default;
59  socket_async_event_args(bool suppress_execution_context_flow);
60 
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;
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_;
136  size_t send_packets_send_size_ = 0;
139  std::any user_token_;
140  };
141  }
142  }
143 }
Implements the Berkeley sockets interface.
Definition: socket.h:63
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.
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.
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.
socket_async_event_args()=default
Creates an empty xtd::net::sockets::socket_async_event_args instance.
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:28
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:26
socket_error
Defines error codes for the xtd::net::sockets::socket class.
Definition: socket_error.h:24
virtual void on_complete(const socket_async_event_args &e)
Represents a method that is called when an asynchronous operation completes.
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:107
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:26
socket_flags
Specifies socket send and receive behaviors. This enumeration has a flags attribute that allows a bit...
Definition: socket_flags.h:24
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:46
Contains xtd::net::sockets::ip_packet_information class.
Contains xtd::net::sockets::socket class.