1#ifndef NEFORCE_NETWORK_FTP_FTP_PROTOCOL_HPP__
2#define NEFORCE_NETWORK_FTP_FTP_PROTOCOL_HPP__
5NEFORCE_BEGIN_NAMESPACE__
11struct NEFORCE_API ftp_exception final : network_exception {
12 explicit ftp_exception(
const char* info =
"FTP Operation Failed.",
const char*
type = static_type,
13 const int code = 0) noexcept :
14 network_exception(info,
type,
code) {}
16 explicit ftp_exception(
const exception& e) :
17 network_exception(e) {}
19 ~ftp_exception()
override =
default;
21 static constexpr auto static_type =
"ftp_exception";
24class NEFORCE_API ftp_protocol :
public ip_socket {
26 enum class transfer_mode {
31 enum class passive_mode {
46 NEFORCE_NODISCARD
bool is_success() const noexcept {
return code >= 200 && code < 400; }
47 NEFORCE_NODISCARD
bool is_positive_preliminary() const noexcept {
return code >= 100 && code < 200; }
54 bool peer_verified =
false;
55 bool data_channel =
false;
58 static constexpr size_t kBufferSize = 8192;
61 bool tls_active_ =
false;
63 ssl_context* ssl_ctx_ =
nullptr;
64 bool data_tls_ =
false;
66 char buffer_[kBufferSize]{};
67 size_t buffer_pos_ = 0;
68 size_t buffer_size_ = 0;
70 ftp_protocol() =
default;
71 ~ftp_protocol()
override =
default;
73 ftp_protocol(ftp_protocol&& other)
noexcept;
74 ftp_protocol&
operator=(ftp_protocol&& other)
noexcept;
80 ssize_t ctrl_recv(
char* buf,
size_t len);
81 bool ctrl_read_line(
string& out);
83 response read_response();
84 void send_response(
int code,
const string& msg);
85 void send_response(
const response& resp);
93NEFORCE_END_NAMESPACE__
int native_handle_type
系统句柄类型
NEFORCE_INLINE17 constexpr none_t none
默认空表示
NEFORCE_NODISCARD NEFORCE_ALWAYS_INLINE constexpr decltype(auto) data(Container &cont) noexcept(noexcept(cont.data()))
获取容器的底层数据指针
exception & operator=(const exception &other) noexcept
复制赋值运算符
exception(const char *info=static_type, const char *type=static_type, const int code=0)
构造函数
NEFORCE_NODISCARD int code() const noexcept
获取异常码
NEFORCE_NODISCARD const char * type() const noexcept
获取异常类型