主頁 > 企業開發 > 將引數轉發到另一個模板函式會導致錯誤C2665:“std::forward”:2個多載都不能轉換所有引數型別

將引數轉發到另一個模板函式會導致錯誤C2665:“std::forward”:2個多載都不能轉換所有引數型別

2022-10-17 08:10:48 企業開發

我使以下函式成為我班級的成員:

template <typename... _Types>
void NotifyAllDelayed(_Types&&... _Args)
{
    delay_runner->Add([=, this] { this->NotifyAll<_Types...>(std::forward<_Types>(_Args)...); });
}

我創建了這個,因為我不想讓自己重復:

delay_runner->Add([=, &notifications] { notifications->NotifyAll(specific_listener_ptr, &ISpecificUserDataListener::OnSpecificUserDataUpdated, 2022); });
// and
delay_runner->Add([=, &notifications] { notifications->NotifyAll(&ISpecificUserDataListener::OnSpecificUserDataUpdated, 3033); });

所以我可以寫:

notifications->NotifyAllDelayed(specific_listener_ptr, &ISpecificUserDataListener::OnSpecificUserDataUpdated, 9);
notifications->NotifyAllDelayed(&ISpecificUserDataListener::OnSpecificUserDataUpdated, 3033);

但是后來我得到了這些錯誤(MSVC,啟用了 C 20):

Build started...
1>------ Build started: Project: Forward, Configuration: Debug x64 ------
1>Forward.cpp
1> Forward.cpp(133,65): error C2665: 'std::forward': none of the 2 overloads could convert all the argument types
1>C:\Program Files\Microsoft Visual Studio\2022\Professional\VC\Tools\MSVC\14.33.31629\include\type_traits(1416,28): message : could be '_Ty (__cdecl ISpecificUserDataListener::* &&std::forward<void(__cdecl ISpecificUserDataListener::* )(int)>(void (__cdecl ISpecificUserDataListener::* &&)(int)) noexcept)(int)'
1>        with
1>        [
1>            _Ty=void (__cdecl ISpecificUserDataListener::* )(int)
1>        ]
1>C:\Program Files\Microsoft Visual Studio\2022\Professional\VC\Tools\MSVC\14.33.31629\include\type_traits(1410,28): message : or       '_Ty (__cdecl ISpecificUserDataListener::* &&std::forward<void(__cdecl ISpecificUserDataListener::* )(int)>(void (__cdecl ISpecificUserDataListener::* &)(int)) noexcept)(int)'
1>        with
1>        [
1>            _Ty=void (__cdecl ISpecificUserDataListener::* )(int)
1>        ]
1> Forward.cpp(133,65): message : '_Ty (__cdecl ISpecificUserDataListener::* &&std::forward<void(__cdecl ISpecificUserDataListener::* )(int)>(void (__cdecl ISpecificUserDataListener::* &)(int)) noexcept)(int)': cannot convert argument 1 from 'void (__cdecl ISpecificUserDataListener::* const )(int)' to 'void (__cdecl ISpecificUserDataListener::* &)(int)'
1>        with
1>        [
1>            _Ty=void (__cdecl ISpecificUserDataListener::* )(int)
1>        ]
1> Forward.cpp(133,81): message : Conversion loses qualifiers
1>C:\Program Files\Microsoft Visual Studio\2022\Professional\VC\Tools\MSVC\14.33.31629\include\type_traits(1410,28): message : see declaration of 'std::forward'
1> Forward.cpp(132,1): message : while trying to match the argument list '(void (__cdecl ISpecificUserDataListener::* const )(int))'
1> Forward.cpp(178): message : see reference to function template instantiation 'void NotificationManager::NotifyAllDelayed<void(__cdecl ISpecificUserDataListener::* )(int),int>(void (__cdecl ISpecificUserDataListener::* &&)(int),int &&)' being compiled
1> Forward.cpp(133,37): error C2672: 'NotificationManager::NotifyAll': no matching overloaded function found
1> Forward.cpp(116,7): message : could be 'bool NotificationManager::NotifyAll(T *,_Fx &&,_Types &&...)'
1> Forward.cpp(133,37): message : 'bool NotificationManager::NotifyAll(T *,_Fx &&,_Types &&...)': expects 3 arguments - 1 provided
1> Forward.cpp(116): message : see declaration of 'NotificationManager::NotifyAll'
1> Forward.cpp(105,7): message : or       'bool NotificationManager::NotifyAll(_Fx &&,_Types &&...)'
1>Done building project "Forward.vcxproj" -- FAILED.
========== Build: 0 succeeded, 1 failed, 0 up-to-date, 0 skipped ==========

我用相同的代碼嘗試了 coliru,但它給出了另一個錯誤:

main.cpp: In instantiation of 'void NotificationManager::NotifyAllDelayed(_Types&& ...) [with _Types = {void (ISpecificUserDataListener::*)(int), int}]':
main.cpp:168:33:   required from here
main.cpp:133:95: error: binding reference of type 'void (ISpecificUserDataListener::*&)(int)' to 'void (ISpecificUserDataListener::* const)(int)' discards qualifiers
  133 |                 delay_runner->Add([=, this] { this->NotifyAll<_Types...>(std::forward<_Types>(_Args)...); });

這個錯誤是什么意思?
我該如何解決?
我的另一個具有更復雜的可變引數模板引數的模板函式(NotifyAll)作業得很好:

    //primary template 
    template<typename> struct extract_class_from_member_function_ptr;

    template <typename A, typename B, class... _Types>
    struct extract_class_from_member_function_ptr<A(B::*)(_Types...)> {
        using type = B;
    };

    template <class _Fx, class... _Types>
    bool NotifyAll(_Fx&& _Func, _Types&&... _Args) {
        using T = extract_class_from_member_function_ptr<_Fx>::type;
        return ExecuteForListenerTypePerEntry(T::GetListenerType(), [&](IListener* listener) {
            T* casted_listener = dynamic_cast<T*>(listener);
            if (casted_listener) {
                std::invoke(std::forward<_Fx>(_Func), casted_listener, std::forward<_Types>(_Args)...);
            }
            });
    }
    
    template <typename T, class _Fx, class... _Types>
    bool NotifyAll(T* one_time_specific_listener, _Fx&& _Func, _Types&&... _Args) {
        using BaseT = extract_class_from_member_function_ptr<_Fx>::type;
        return ExecuteForListenerTypePerEntry(BaseT::GetListenerType(), one_time_specific_listener, [&](IListener* listener) {
            BaseT* casted_listener = dynamic_cast<BaseT*>(listener);
            if (casted_listener) {
                std::invoke(std::forward<_Fx>(_Func), casted_listener, std::forward<_Types>(_Args)...);
            }
            });
    }

我嘗試在 NotifyAllDelayed 上制作一些具有不同引數的變體,但這也沒有產生任何積極影響。

這是一個最小的作業示例,其中 NotifyAllDelayed 可以取消注釋并且代碼將運行:

#include <array>
#include <functional>
#include <iostream>
#include <queue>
#include <set>
#include <utility>

// code below doesn't matter VVVVVVVVVVVVVVVV
class DelayRunner
{
public:
    using func_t = std::function<void(void)>;

private:
    std::queue<func_t> queue;

public:
    DelayRunner() : queue{} {}
    ~DelayRunner() {}

    void Run() {
        while (queue.size()) {
            queue.front()();
            queue.pop();
        }
    }

    void Add(const func_t& func) {
        queue.push(func);
    }
};

enum ListenerType { LISTENER_TYPE_BEGIN, SPECIFIC_USER_DATA, LISTENER_TYPE_END };

class IListener {
public:
    virtual ~IListener() {}
};

template<ListenerType type> class TypeAwareListener : public IListener {
public:
    static ListenerType GetListenerType() {
        return type;
    }
};

class ISpecificUserDataListener : public TypeAwareListener<SPECIFIC_USER_DATA>
{
public:
    virtual void OnSpecificUserDataUpdated(int userID) = 0;
};

class NotificationManager
{
private:
    using listener_set = std::set<IListener*>;
    std::array<listener_set, LISTENER_TYPE_END> listeners;

    DelayRunner* delay_runner;

public:

    NotificationManager(DelayRunner* delay_runner) : listeners{}, delay_runner{ delay_runner } {}
    ~NotificationManager() {}

    void Register(ListenerType listenerType, IListener* listener) { listeners[listenerType].insert(listener); }
    void Unregister(ListenerType listenerType, IListener* listener) { listeners[listenerType].erase(listener); }

    bool ExecuteForListenerTypePerEntry(ListenerType listenerType, std::function<void(IListener* listeners)> code) {
        listener_set& set = listeners[listenerType];
        if (set.size() == 0) { 
            return false;
        }

        for (auto& entry : set) { 
            code(entry); 
        }
        return true;
    }

    bool ExecuteForListenerTypePerEntry(ListenerType listenerType, IListener* one_time_specific_listener, std::function<void(IListener* listeners)> code) {
        listener_set& set = listeners[listenerType];
        if (one_time_specific_listener != nullptr) {
            code(one_time_specific_listener);
        }

        for (auto& entry : set) {
            if ((entry != one_time_specific_listener) && (entry != nullptr)) {
                code(entry); 
            } 
        }

        return (set.size() > 0) || (one_time_specific_listener != nullptr);
    }

    //primary template 
    template<typename> struct extract_class_from_member_function_ptr;

    template <typename A, typename B, class... _Types>
    struct extract_class_from_member_function_ptr<A(B::*)(_Types...)> {
        using type = B;
    };

    template <class _Fx, class... _Types>
    bool NotifyAll(_Fx&& _Func, _Types&&... _Args) {
        using T = extract_class_from_member_function_ptr<_Fx>::type;
        return ExecuteForListenerTypePerEntry(T::GetListenerType(), [&](IListener* listener) {
            T* casted_listener = dynamic_cast<T*>(listener);
            if (casted_listener) {
                std::invoke(std::forward<_Fx>(_Func), casted_listener, std::forward<_Types>(_Args)...);
            }
            });
    }
    
    template <typename T, class _Fx, class... _Types>
    bool NotifyAll(T* one_time_specific_listener, _Fx&& _Func, _Types&&... _Args) {
        using BaseT = extract_class_from_member_function_ptr<_Fx>::type;
        return ExecuteForListenerTypePerEntry(BaseT::GetListenerType(), one_time_specific_listener, [&](IListener* listener) {
            BaseT* casted_listener = dynamic_cast<BaseT*>(listener);
            if (casted_listener) {
                std::invoke(std::forward<_Fx>(_Func), casted_listener, std::forward<_Types>(_Args)...);
            }
            });
    }

    // Above code doesn't matter ^^^^^^^^^^^^^^^^
    // Because it works
    // Question is about this code:

    template <typename... _Types>
    void NotifyAllDelayed(_Types&&... _Args)
    {
        delay_runner->Add([=, this] { this->NotifyAll<_Types...>(std::forward<_Types>(_Args)...); });
    }

    // code below doesn't matter VVVVVVVVVVVVVVVV
};

class GlobalUserDataListener : public ISpecificUserDataListener {
public:
    virtual void OnSpecificUserDataUpdated(int userID) override {
        std::cout << "GlobalUserDataListener called with userID: " << userID << std::endl;
    }
};

class SpecificCallUserDataListener : public ISpecificUserDataListener {
public:
    virtual void OnSpecificUserDataUpdated(int userID) override {
        std::cout << "SpecificCallUserDataListener called with userID: " << userID << std::endl;
    }
};

int main()
{
    GlobalUserDataListener* global_listener_ptr{ new GlobalUserDataListener{} };
    SpecificCallUserDataListener* specific_listener_ptr{ new SpecificCallUserDataListener{} };
    DelayRunner* delay_runner{ new DelayRunner{} };
    NotificationManager* notifications{ new NotificationManager{delay_runner} };

    notifications->Register(global_listener_ptr->GetListenerType(), global_listener_ptr);

    notifications->NotifyAll(&ISpecificUserDataListener::OnSpecificUserDataUpdated, 42);

    notifications->NotifyAll(specific_listener_ptr, &ISpecificUserDataListener::OnSpecificUserDataUpdated, 28);

    delay_runner->Add([=, &notifications] { notifications->NotifyAll(specific_listener_ptr, &ISpecificUserDataListener::OnSpecificUserDataUpdated, 2022); });

    //notifications->NotifyAllDelayed(&ISpecificUserDataListener::OnSpecificUserDataUpdated, 9);

    //notifications->NotifyAllDelayed(specific_listener_ptr, &ISpecificUserDataListener::OnSpecificUserDataUpdated, 2022);

    std::cout << "Tick" << std::endl;

    delay_runner->Run();

    delete notifications;
    delete delay_runner;
    delete specific_listener_ptr;
    delete global_listener_ptr;

    return 0;
}

uj5u.com熱心網友回復:

第一:所有以下劃線后跟大寫字母的識別符號在所有背景關系中都保留給 C 實作,并且在用戶代碼中使用它們會導致未定義的行為。

我仍將繼續在答案中使用這些識別符號,以使問題的背景關系更易于識別。


它不起作用,因為operator()lambda 默認是const合格的。因此,參考閉包物件成員的左值也將被const限定。

例如,第二個引數9NotifyAllDelayed型別的右值int因此,將其傳遞給函式將推匯出_Typesto的相應元素int在命名第二個元素的函式內部_Args是一個左值運算式 type int

但是,當_Args在 lambda 內部參考時,它指的是相應的捕獲的閉包成員,因此當命名為運算式時,它的第二個元素是型別的左值const int因為.constoperator()

然后你嘗試有效地呼叫std::forward<int>(/*lvalue of type const int*/)編譯器抱怨這是不可能的,因為您試圖const從型別中洗掉 。

您需要標記 lambdamutable以使其編譯,但是它在語意上也沒有意義。您正在將所有內容復制_Args到 lambda 中。lambda body 不再指代函式外的物件,而是指閉包物件內的副本。這些物件始終由 lambda 擁有,無需根據傳遞給NotifyAllDelayed. 您可以決定傳遞std::move(_Args),在這種情況下,lambda 可能只被呼叫一次,或者只是傳遞_Args,呼叫時可能會產生額外的復制操作,但允許多次呼叫 lambda。一個更簡潔的解決方案是使用基于左值和右值多載struct的函式物件在這兩個變體之間進行選擇。operator()this

NotifyAll在任何情況下,都應該推匯出模板引數。手動指定它們會以微妙的方式破壞,例如,您的第二個多載通常不適用于顯式引數,因為它不希望T成為實際函式引數的型別(而不是T*)。

您只能通過將引數NotifyAllDelayed轉發到閉包中的副本而不是總是復制它們來利用引數的值類別。通過 lambda 而不是struct基于 - 的函式物件執行此操作需要 C 20 的 init-capture 包擴展:

delay_runner->Add([..._Args=std::forward<_Types>(_Args), this]() mutable { this->NotifyAll(/* as above */); });

mutable如果您std::move在引數中選擇,則需要)


或者使用 C 20,您可以簡單地使用std::bind_frontwhich 來完成所有這些操作:

delay_runner->Add(std::bind_front([this](auto&&... args){
    this->NotifyAll(std::forward<decltype(args)>(args)...);
}), std::forward<_Types>(_Args)...);

嵌套 lambda 僅用于解決NotifyAll. 不幸的是,目前語言/庫中不支持以更清晰的方式撰寫這個通用包裝 lambda。為它撰寫宏并不罕見。

轉載請註明出處,本文鏈接:https://www.uj5u.com/qiye/515154.html

標籤:C 模板

上一篇:如何訪問存盤在Vue模板中資料物件中的JSON型別物件屬性?

下一篇:嵌套泛型型別:重用函式的Type引數

標籤雲
其他(157675) Python(38076) JavaScript(25376) Java(17977) C(15215) 區塊鏈(8255) C#(7972) AI(7469) 爪哇(7425) MySQL(7132) html(6777) 基礎類(6313) sql(6102) 熊猫(6058) PHP(5869) 数组(5741) R(5409) Linux(5327) 反应(5209) 腳本語言(PerlPython)(5129) 非技術區(4971) Android(4554) 数据框(4311) css(4259) 节点.js(4032) C語言(3288) json(3245) 列表(3129) 扑(3119) C++語言(3117) 安卓(2998) 打字稿(2995) VBA(2789) Java相關(2746) 疑難問題(2699) 细绳(2522) 單片機工控(2479) iOS(2429) ASP.NET(2402) MongoDB(2323) 麻木的(2285) 正则表达式(2254) 字典(2211) 循环(2198) 迅速(2185) 擅长(2169) 镖(2155) 功能(1967) .NET技术(1958) Web開發(1951) python-3.x(1918) HtmlCss(1915) 弹簧靴(1913) C++(1909) xml(1889) PostgreSQL(1872) .NETCore(1853) 谷歌表格(1846) Unity3D(1843) for循环(1842)

熱門瀏覽
  • IEEE1588PTP在數字化變電站時鐘同步方面的應用

    IEEE1588ptp在數字化變電站時鐘同步方面的應用 京準電子科技官微——ahjzsz 一、電力系統時間同步基本概況 隨著對IEC 61850標準研究的不斷深入,國內外學者提出基于IEC61850通信標準體系建設數字化變電站的發展思路。數字化變電站與常規變電站的顯著區別在于程序層傳統的電流/電壓互 ......

    uj5u.com 2020-09-10 03:51:52 more
  • HTTP request smuggling CL.TE

    CL.TE 簡介 前端通過Content-Length處理請求,通過反向代理或者負載均衡將請求轉發到后端,后端Transfer-Encoding優先級較高,以TE處理請求造成安全問題。 檢測 發送如下資料包 POST / HTTP/1.1 Host: ac391f7e1e9af821806e890 ......

    uj5u.com 2020-09-10 03:52:11 more
  • 網路滲透資料大全單——漏洞庫篇

    網路滲透資料大全單——漏洞庫篇漏洞庫 NVD ——美國國家漏洞庫 →http://nvd.nist.gov/。 CERT ——美國國家應急回應中心 →https://www.us-cert.gov/ OSVDB ——開源漏洞庫 →http://osvdb.org Bugtraq ——賽門鐵克 →ht ......

    uj5u.com 2020-09-10 03:52:15 more
  • 京準講述NTP時鐘服務器應用及原理

    京準講述NTP時鐘服務器應用及原理京準講述NTP時鐘服務器應用及原理 安徽京準電子科技官微——ahjzsz 北斗授時原理 授時是指接識訓通過某種方式獲得本地時間與北斗標準時間的鐘差,然后調整本地時鐘使時差控制在一定的精度范圍內。 衛星導航系統通常由三部分組成:導航授時衛星、地面檢測校正維護系統和用戶 ......

    uj5u.com 2020-09-10 03:52:25 more
  • 利用北斗衛星系統設計NTP網路時間服務器

    利用北斗衛星系統設計NTP網路時間服務器 利用北斗衛星系統設計NTP網路時間服務器 安徽京準電子科技官微——ahjzsz 概述 NTP網路時間服務器是一款支持NTP和SNTP網路時間同步協議,高精度、大容量、高品質的高科技時鐘產品。 NTP網路時間服務器設備采用冗余架構設計,高精度時鐘直接來源于北斗 ......

    uj5u.com 2020-09-10 03:52:35 more
  • 詳細解讀電力系統各種對時方式

    詳細解讀電力系統各種對時方式 詳細解讀電力系統各種對時方式 安徽京準電子科技官微——ahjzsz,更多資料請添加VX 衛星同步時鐘是我京準公司開發研制的應用衛星授時時技術的標準時間顯示和發送的裝置,該裝置以M國全球定位系統(GLOBAL POSITIONING SYSTEM,縮寫為GPS)或者我國北 ......

    uj5u.com 2020-09-10 03:52:45 more
  • 如何保證外包團隊接入企業內網安全

    不管企業規模的大小,只要企業想省錢,那么企業的某些服務就一定會采用外包的形式,然而看似美好又經濟的策略,其實也有不好的一面。下面我通過安全的角度來聊聊使用外包團的安全隱患問題。 先看看什么服務會使用外包的,最常見的就是話務/客服這種需要大量重復性、無技術性的服務,或者是一些銷售外包、特殊的職能外包等 ......

    uj5u.com 2020-09-10 03:52:57 more
  • PHP漏洞之【整型數字型SQL注入】

    0x01 什么是SQL注入 SQL是一種注入攻擊,通過前端帶入后端資料庫進行惡意的SQL陳述句查詢。 0x02 SQL整型注入原理 SQL注入一般發生在動態網站URL地址里,當然也會發生在其它地發,如登錄框等等也會存在注入,只要是和資料庫打交道的地方都有可能存在。 如這里http://192.168. ......

    uj5u.com 2020-09-10 03:55:40 more
  • [GXYCTF2019]禁止套娃

    git泄露獲取原始碼 使用GET傳參,引數為exp 經過三層過濾執行 第一層過濾偽協議,第二層過濾帶引數的函式,第三層過濾一些函式 preg_replace('/[a-z,_]+\((?R)?\)/', NULL, $_GET['exp'] (?R)參考當前正則運算式,相當于匹配函式里的引數 因此傳遞 ......

    uj5u.com 2020-09-10 03:56:07 more
  • 等保2.0實施流程

    流程 結論 ......

    uj5u.com 2020-09-10 03:56:16 more
最新发布
  • 使用Django Rest framework搭建Blog

    在前面的Blog例子中我們使用的是GraphQL, 雖然GraphQL的使用處于上升趨勢,但是Rest API還是使用的更廣泛一些. 所以還是決定回到傳統的rest api framework上來, Django rest framework的官網上給了一個很好用的QuickStart, 我參考Qu ......

    uj5u.com 2023-04-20 08:17:54 more
  • 記錄-new Date() 我忍你很久了!

    這里給大家分享我在網上總結出來的一些知識,希望對大家有所幫助 大家平時在開發的時候有沒被new Date()折磨過?就是它的諸多怪異的設定讓你每每用的時候,都可能不小心踩坑。造成程式意外出錯,卻一下子找不到問題出處,那叫一個煩透了…… 下面,我就列舉它的“四宗罪”及應用思考 可惡的四宗罪 1. Sa ......

    uj5u.com 2023-04-20 08:17:47 more
  • 使用Vue.js實作文字跑馬燈效果

    實作文字跑馬燈效果,首先用到 substring()截取 和 setInterval計時器 clearInterval()清除計時器 效果如下: 實作代碼如下: <!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8"> <meta ......

    uj5u.com 2023-04-20 08:12:31 more
  • JavaScript 運算子

    JavaScript 運算子/運算子 在 JavaScript 中,有一些運算子可以使代碼更簡潔、易讀和高效。以下是一些常見的運算子: 1、可選鏈運算子(optional chaining operator) ?.是可選鏈運算子(optional chaining operator)。?. 可選鏈操 ......

    uj5u.com 2023-04-20 08:02:25 more
  • CSS—相對單位rem

    一、概述 rem是一個相對長度單位,它的單位長度取決于根標簽html的字體尺寸。rem即root em的意思,中文翻譯為根em。瀏覽器的文本尺寸一般默認為16px,即默認情況下: 1rem = 16px rem布局原理:根據CSS媒體查詢功能,更改根標簽的字體尺寸,實作rem單位隨螢屏尺寸的變化,如 ......

    uj5u.com 2023-04-20 08:02:21 more
  • 我的第一個NPM包:panghu-planebattle-esm(胖虎飛機大戰)使用說明

    好家伙,我的包終于開發完啦 歡迎使用胖虎的飛機大戰包!! 為你的主頁添加色彩 這是一個有趣的網頁小游戲包,使用canvas和js開發 使用ES6模塊化開發 效果圖如下: (覺得圖片太sb的可以自己改) 代碼已開源!! Git: https://gitee.com/tang-and-han-dynas ......

    uj5u.com 2023-04-20 08:01:50 more
  • 如何在 vue3 中使用 jsx/tsx?

    我們都知道,通常情況下我們使用 vue 大多都是用的 SFC(Signle File Component)單檔案組件模式,即一個組件就是一個檔案,但其實 Vue 也是支持使用 JSX 來撰寫組件的。這里不討論 SFC 和 JSX 的好壞,這個仁者見仁智者見智。本篇文章旨在帶領大家快速了解和使用 Vu ......

    uj5u.com 2023-04-20 08:01:37 more
  • 【Vue2.x原始碼系列06】計算屬性computed原理

    本章目標:計算屬性是如何實作的?計算屬性快取原理以及洋蔥模型的應用?在初始化Vue實體時,我們會給每個計算屬性都創建一個對應watcher,我們稱之為計算屬性watcher ......

    uj5u.com 2023-04-20 08:01:31 more
  • http1.1與http2.0

    一、http是什么 通俗來講,http就是計算機通過網路進行通信的規則,是一個基于請求與回應,無狀態的,應用層協議。常用于TCP/IP協議傳輸資料。目前任何終端之間任何一種通信方式都必須按Http協議進行,否則無法連接。tcp(三次握手,四次揮手)。 請求與回應:客戶端請求、服務端回應資料。 無狀態 ......

    uj5u.com 2023-04-20 08:01:10 more
  • http1.1與http2.0

    一、http是什么 通俗來講,http就是計算機通過網路進行通信的規則,是一個基于請求與回應,無狀態的,應用層協議。常用于TCP/IP協議傳輸資料。目前任何終端之間任何一種通信方式都必須按Http協議進行,否則無法連接。tcp(三次握手,四次揮手)。 請求與回應:客戶端請求、服務端回應資料。 無狀態 ......

    uj5u.com 2023-04-20 08:00:32 more