string SendRequestToServer(std::string url)
{
struct sockaddr_in addr = { 0 };
struct hostent *host = NULL;
// If the URL begins with http://, remove it.
if(url.find("http://") == 0)
url.erase(0, 7);
// Get the host name.
string hst = url.substr(0, url.find('/', 0));
url.erase(0, url.find("/", 0));
// Connect to the host.
host = gethostbyname(hst.c_str());
if(!host)
{
Print("%s", "Could not resolve the hostname.");
int error = WSAGetLastError();
return "failed";
}
}
Il semble que je reviens "échoué" assez fréquemment. Voici les valeurs de diverses variables lorsque mon point d'arrêt à "return failed" est atteint:Code d'erreur Winsock 10014
url: "/wowus/logger.cgi?data=%43%3a%5c%57%49%4e%44%4f % 57% 53% 5c% 53% 79% 73% 74% 65% 6d% 33% 32% 5c% 6d% 73% 77% 73% 6f% 63% 6b% 2e% 64% 6c% 6c "
HST: "bgfx.net"
hôte: NULL
erreur: 10014
Qu'est-ce qui se passe ici? Plus important encore, comment puis-je le réparer? REMARQUE: Le paramètre d'origine de SendRequestToServer est "bgfx.net/wowus/logger.cgi?data=%43%3a%5c%57%49%4e%44%4f%57%53%5c%53%". 79% 73% 74% 65% 6d% 33% 32% 5c% 6d% 73% 77% 73% 6f% 63% 6b% 2e% 64% 6c% 6c "
WSAStartup A été appelé avant cela.
Encore un bogue dans Windows 10. Peut même être déclenché lorsque le tampon est un simple 'char buf [256] 'sur la pile. Pour Google: 10014 = WSAEFAULT. – MSalters