Why am I receiving 67 code from QOSStartTrackingClient method?
Asked Answered
N

1

7

I am receiving error code 67 from the code below, which means ERROR_BAD_NET_NAME.

Why is it happening? How can I fix it?

SOCKADDR address;
strcpy_s(address.sa_data, "8.8.8.8");
address.sa_family = AF_INET;

if (!QOSStartTrackingClient(QoSHandle, &address, 0))
    cout << GetLastError();
Newspaper answered 10/5, 2017 at 17:43 Comment(1)
of course you initialize SOCKADDR wrong. by fact this must be sockaddr_in. it not accept string for ip. only in binary form as ULONG S_addrVitrics
V
0

you initialize SOCKADDR wrong :

strcpy_s(address.sa_data, "8.8.8.8"); - this is mistake.

really SOCKADDR is only place holder

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.

and from here

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.

in your case you need use 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();
Vitrics answered 10/5, 2017 at 18:7 Comment(4)
it looks like inet_addr is deprecated.Newspaper
I used inet_pton(AF_INET, "8.8.8.8", &sa.sin_addr); instead but I still receive 67Newspaper
@MatinLotfaliee but SOCKADDR_IN sa = { AF_INET }; you execute before inet_pton(AF_INET, "8.8.8.8", &sa.sin_addr); ?Vitrics
Yes. I execute it before inet_ptonNewspaper

© 2022 - 2024 — McMap. All rights reserved.