小编Paz*_*aze的帖子

如何创建/设计数据结构?

我是一个知道相当多的C++和其他编程语言的中级爱好程序员,现在我正在尝试使用原始套接字而不是c ++中的熟插槽,但是当我查看样本和其他人的源代码时(出于学习目的,我没看到)我可以看到他们都知道如何为网络层制作标题,例如他们写了一个像这样的ip标头结构:

struct IP_HEADER
{
    BYTE  ver_ihl;        // Version (4 bits) and Internet Header Length (4 bits)
    BYTE  type;           // Type of Service (8 bits)
    WORD  length;         // Total size of packet (header + data)(16 bits)
    WORD  packet_id;      // (16 bits)
    WORD  flags_foff;     // Flags (3 bits) and Fragment Offset (13 bits)
    BYTE  time_to_live;   // (8 bits)
    BYTE  protocol;       // (8 bits)
    WORD  hdr_chksum;     // Header check sum (16 bits)
    DWORD source_ip;      // Source Address (32 bits)
    DWORD destination_ip; // …
Run Code Online (Sandbox Code Playgroud)

c++ networking struct network-programming data-structures

1
推荐指数
1
解决办法
126
查看次数