- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
我收到错误代码 67
从下面的代码,这意味着ERROR_BAD_NET_NAME
.
为什么会这样?我该如何解决?
SOCKADDR address;
strcpy_s(address.sa_data, "8.8.8.8");
address.sa_family = AF_INET;
if (!QOSStartTrackingClient(QoSHandle, &address, 0))
cout << GetLastError();
最佳答案
你初始化 SOCKADDR
错误的 :strcpy_s(address.sa_data, "8.8.8.8");
- 这是错误的。
真的 SOCKADDR
只是占位符
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.
To actually fill in values for each part of an address, you use the SOCKADDR_IN data structure, which is specifically for this address format. The SOCKADDR and the SOCKADDR_IN data structures are the same size. You simply cast to switch between the two structure types.
SOCKADDR_IN
SOCKADDR_IN sa = { AF_INET };
sa.sin_addr.s_addr = inet_addr("8.8.8.8");
if (!QOSStartTrackingClient(QoSHandle, (SOCKADDR*)&sa, 0))
cout << GetLastError();
关于winapi - 为什么我从 QOSStartTrackingClient 方法收到 67 码?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/43899408/
我收到错误代码 67从下面的代码,这意味着ERROR_BAD_NET_NAME . 为什么会这样?我该如何解决? SOCKADDR address; strcpy_s(address.sa_data,
我是一名优秀的程序员,十分优秀!