The sockaddr structure varies depending on the protocol selected. Except for the sa_family parameter, sockaddr contents are expressed in network byte order.//sockaddr struct 随着所选则的协议而变化, // // struct sockaddr { u_short sa_family; char sa_data[14]; }; In Windows Sockets 2, the name parameter is not strictly interpreted as a pointer to a sockaddr structure. It is presented in this manner for Windows Sockets compatibility. The actual 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.The structure below is used with TCP/IP. Other protocols use similar structures. //struct sockaddr_in 被用于 TCP/IP //其他协议用类似的结构 struct sockaddr_in { short sin_family; u_short sin_port; struct in_addr sin_addr; char sin_zero[8]; }; q:使用sendto发送缓冲区的数据后,缓冲区的数据还存在吗? a:不存在了。(注意你使用的 flags)
//
//
struct sockaddr {
u_short sa_family;
char sa_data[14];
};
In Windows Sockets 2, the name parameter is not strictly interpreted as a pointer to a sockaddr structure. It is presented in this manner for Windows Sockets compatibility. The actual 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.The structure below is used with TCP/IP. Other protocols use similar structures. //struct sockaddr_in 被用于 TCP/IP
//其他协议用类似的结构
struct sockaddr_in {
short sin_family;
u_short sin_port;
struct in_addr sin_addr;
char sin_zero[8];
};
q:使用sendto发送缓冲区的数据后,缓冲区的数据还存在吗?
a:不存在了。(注意你使用的 flags)