• 您現在的位置是:首頁 >生活 > 2022-12-22 08:15:26 來源:

    soc開發軟件(sockaddr)

    導讀 大家好,小霞來為大家解答以上的問題。soc開發軟件,sockaddr這個很多人還不知道,現在讓我們一起來看看吧!1、因為sendto的參數要的就是(st

    大家好,小霞來為大家解答以上的問題。soc開發軟件,sockaddr這個很多人還不知道,現在讓我們一起來看看吧!

    1、因為sendto的參數要的就是(struct sockaddr *)類型的參數,這個結構可以支持多種地址類型,典型的例子就是ipv4和ipv6。

    2、但是通常你的接受端的地址是通過地址解析得到的,sockaddr_in(對應ipv4)或者是sockaddr_in6(對應Ipv6),而不是struct sockaddr,所以需要類型轉換。

    3、至于如何區分指向的到底是什么類型的地址,主要依靠第一個字段ushort sa_family;來區分。

    4、MSDN里面的描述是:Winsock functions using sockaddr are not strictly interpreted to be pointers to a sockaddr structure. The structure is interpreted differently in the context of different address families. The only requirements are that the first u_short is the address family and the total size of the memory buffer in bytes is namelen.。

    本文到此分享完畢,希望對大家有所幫助。

  • 成人app