我知道WSARecvFrom有一個參數,用於返回發件人的IP地址。但是,當我將它與重疊的io一起使用時,我傳遞的變量不會被填充。使用重疊的IO獲取發件人的IP地址
WSARecvFrom(udpSocket, &receiveBuffer, 1, 0, &flags, (sockaddr*)&incomingAddress, &SocketAddressSize, &receiveOverlapped, 0)
...
WSAWaitForMultipleEvents(2, networkEvents, false, WSA_INFINITE, false)
...
WSAGetOverlappedResult(udpSocket, &receiveOverlapped, &transferCount, true, &flags);
...
char* incomingAddressString = inet_ntoa(incomingAddress.sin_addr);
incomingAddressString現在等於 「204.204.204.204」
我缺少的東西?
感謝
考慮使用ASIO http://think-async.com/Asio/ – 2011-12-20 21:53:11