+ delay = rand() % (UDP_MAX_DELAY - UDP_MIN_DELAY + 1) + UDP_MIN_DELAY;
Using rand() for this doesn't seem very random, and it could interfere with an application's use of rand().
+ /* Get size of buffer for adapters */ + adapterAddresses = (IP_ADAPTER_ADDRESSES *) HeapAlloc(heap, 0, bufferSize);
Was this comment meant to be earlier?
Sending messages to every adapter in sequence, with a delay for each, doesn't seem right.
+void terminate_networking(IWSDiscoveryPublisherImpl *impl) +{ + impl->publisherStarted = FALSE; + + WSACleanup(); +}
It seems like this will call WSACleanup even when freeing an object that was never used.
On 27/07/2017 21:22, Vincent Povirk wrote:
Using rand() for this doesn't seem very random, and it could interfere with an application's use of rand().
I've altered this to use BCryptGenRandom instead.
Sending messages to every adapter in sequence, with a delay for each, doesn't seem right.
The spec doesn't explicitly state how multiple adapters should be handled. The SOAP over UDP spec just suggests how multicast messages should be sent (including delays and repeats as appropriate). However, I've changed this now so that a new thread is spawned for each adapter's transmission, which should reduce the overall time taken, and will also allow the Publish/UnPublish etc method to return immediately (or near enough), which appears to be the behaviour on Windows, as you've pointed out.
It seems like this will call WSACleanup even when freeing an object that was never used.
Thanks, I've amended this too.