I’m trying to list available interfaces using the WSAIoctl function. I have to pass in a buffer to hold the complete list. I want to get a count of the interfaces before I allocate memory to hold the interface details but if I pass in a NULL pointer the call just fails (I dont get a valid count returned). Any way to get this count befor I have to allocate memory?
Background is that I am starting a load of processes/threads on on Windows machine which all connect to a single server. I want the server to see these individual connections as coming from different IP addresses and I have added a load of aliases to the test machine to allow for this (lots). The WSAIoct does correctly find all the ones I added.
Cheers…
From the msdn documentation for WSAIoctl:
So you have to call the WSAIoctl function twice. The first time with an arbitrary buffer and then check for the error codes mentioned in the documentation. Then use the the size returned in lpcbBytesReturned to allocate the buffer and call the WSAIoctl function a second time.