WSA Error 10014



  • Ich versuche derzeit eine Verbindung zu einem Server über den Port 80 herzustellen, komischerweise funktioniert das nicht ganz so wie ich es gerne hätte. Die connect Funktion schlägt fehl und liefert den Code 10014 zurück. "The system detected an invalid pointer address in attempting to use a pointer argument of a call. This error occurs if an application passes an invalid pointer value, or if the length of the buffer is too small. For instance, if the length of an argument, which is a sockaddr structure, is smaller than the sizeof(sockaddr)." Mit dem Debugger habe ich ebenfalls fleißig gesucht und nichts gefunden.

    Ich hab die Methode für euch einmal sehr klein zusammen gefasst.

    bool HTTP::sconnect(const char *ip)
    {
    	//...
    
    	this->address.sin_addr.s_addr = inet_addr(ip);
    	this->address.sin_port = htons(80);
    	this->address.sin_family = AF_INET;
    
    	this->result = ioctlsocket(this->csocket, FIONBIO, &this->mode);
    	if(this->result != NO_ERROR)
    	{
    		return false;
    	}
    
    	if(connect(this->csocket, reinterpret_cast<SOCKADDR *>(&this->address), sizeof(this->address) == false))
    	{
    		return false;
    	}
    
    	//...
    }
    

    Einiges wie this->mode zum Beispiel wird im Konstruktor initialisiert. Vielleicht kann mir ja jemand von euch helfen.

    MfG
    Helmut



  • Sieh dir noch einmal ganz genau die Klammersetzung in der connect -Zeile an.
    Und dann liest du nach, was connect zurückgibt, denn das ist kein bool .



  • Hoppala 😃 Danke für den Hinweis, ich sollte wohl doch schlafen gehen. Klappt jetzt alles!


Anmelden zum Antworten