IdentifiantMot de passe
Loading...
Mot de passe oublié ?Je m'inscris ! (gratuit)
Navigation

Inscrivez-vous gratuitement
pour pouvoir participer, suivre les réponses en temps réel, voter pour les messages, poser vos propres questions et recevoir la newsletter

C++ Discussion :

Socket qui ne marche pas


Sujet :

C++

  1. #1
    Membre confirmé
    Profil pro
    Inscrit en
    Novembre 2005
    Messages
    124
    Détails du profil
    Informations personnelles :
    Localisation : France

    Informations forums :
    Inscription : Novembre 2005
    Messages : 124
    Par défaut Socket qui ne marche pas
    J'ai besion de faire un socket, donc j'en ai récuperer un sur internet
    c'est ok toutes les page marche : html,php.
    Mais juste sur le site que je doit me connecter sa ne marche pas ! (les page php marche pas, mais html oui) voila l'erreur renvoyer :
    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
    20
    21
    22
    23
    24
     
    HTTP/1.1 500 Internal Server Error
    Date: Sun, 15 Jan 2006 11:12:25 GMT
    Server: Apache/1.3.33 (Unix)
    Connection: close
    Content-Type: text/html; charset=iso-8859-1
     
    <!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML 2.0//EN">
    <HTML><HEAD>
    <TITLE>500 Internal Server Error</TITLE>
    </HEAD><BODY>
    <H1>Internal Server Error</H1>
    The server encountered an internal error or
    misconfiguration and was unable to complete
    your request.<P>
    Please contact the server administrator,
     webadmin@kundenserver.de and inform them of the time the error occurred,
    and anything you might have done that may have
    caused the error.<P>
    More information about this error may be available
    in the server error log.<P>
    <P>Additionally, a 500 Internal Server Error
    error was encountered while trying to use an ErrorDocument to handle the request.
    </BODY></HTML>
    Le code du socket :
    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
    20
    21
    22
    23
    24
    25
     
         SOCKET W_IP;
         IN_ADDR Adresse;
         SOCKADDR_IN SockAddrIn;
         HOSTENT * Hote;
         WSADATA WSAData;
         char Buffer[9999] = "";
         static char IP[16];
     
         WSAStartup(0x0202, &WSAData);
         W_IP = socket(AF_INET, SOCK_STREAM, IPPROTO_TCP);
         Hote = gethostbyname("helicoptere-avis.com");
         memcpy(&Adresse, Hote -> h_addr, Hote -> h_length);
         SockAddrIn.sin_family = AF_INET;
         SockAddrIn.sin_port = htons(80);
             SockAddrIn.sin_addr = Adresse;
         connect(W_IP, (SOCKADDR *)&SockAddrIn, sizeof(SockAddrIn));
         sprintf(Buffer, "%s", "GET  http://helicoptere-avis.com/index.php HTTP/1.0 \n\n");
         send(W_IP, Buffer, strlen(Buffer), 0);
         recv(W_IP, Buffer, sizeof(Buffer), 0);
         ofstream log("protsock.log");
         log << Buffer;
         SetDlgItemText(hDlg, 155, Buffer); 
         closesocket(W_IP);
         WSACleanup();
    Je ne comprend pas sur le site en question les page html marche (je reçois le code de la page, mais avec php je reçois l'erreur ci-dessus)
    Je rappelle que sur d'autre site ça marche !
    L'hébergeur et 1&1 http://commander.1and1.fr/
    compiler avec devc++
    Merci de vos reponces

  2. #2
    Membre éprouvé
    Homme Profil pro
    Développeur de jeux vidéo
    Inscrit en
    Décembre 2005
    Messages
    109
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Âge : 40
    Localisation : France, Paris (Île de France)

    Informations professionnelles :
    Activité : Développeur de jeux vidéo
    Secteur : Tourisme - Loisirs

    Informations forums :
    Inscription : Décembre 2005
    Messages : 109
    Par défaut
    Apparament le serveur distant n'accepte pas la forme de ta requête.

    Essaye en ajoutant l'entête "Host"

  3. #3
    Membre confirmé
    Profil pro
    Inscrit en
    Novembre 2005
    Messages
    124
    Détails du profil
    Informations personnelles :
    Localisation : France

    Informations forums :
    Inscription : Novembre 2005
    Messages : 124
    Par défaut
    merci
    j'ai esssayer en ajoutant "Host: helicoptere-avis.com" et toujour pareil
    je vien de remarquer que le serveur et sous linux (unix) peut etre ....

  4. #4
    Membre éprouvé
    Homme Profil pro
    Développeur de jeux vidéo
    Inscrit en
    Décembre 2005
    Messages
    109
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Âge : 40
    Localisation : France, Paris (Île de France)

    Informations professionnelles :
    Activité : Développeur de jeux vidéo
    Secteur : Tourisme - Loisirs

    Informations forums :
    Inscription : Décembre 2005
    Messages : 109
    Par défaut
    J'ai aussi essayé avec l'entête Host, et ça fonctionne très bien

    Voici la requête que j'envoi :
    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    GET http://helicoptere-avis.com/index.php HTTP/1.0\r\nHost: helicoptere-avis.com\r\n\r\n

  5. #5
    Membre confirmé
    Profil pro
    Inscrit en
    Novembre 2005
    Messages
    124
    Détails du profil
    Informations personnelles :
    Localisation : France

    Informations forums :
    Inscription : Novembre 2005
    Messages : 124
    Par défaut
    Bizzard, mais j'ai trouver un truc qui marche bien
    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    char * pFile;
    DWORD dwFileSize = 0, dwByteRead = 0;
    DWORD dwContext = 0;
    char szURL[] = "http://helicoptere-avis.com/FlightRecorder/essai.php";
    HINTERNET hSession, hUrl;
    hSession = InternetOpen("test", INTERNET_OPEN_TYPE_DIRECT, 0, 0, 0);
    if(hSession == NULL) return 0;
    hUrl = InternetOpenUrl(hSession, szURL, 0, 0, INTERNET_FLAG_EXISTING_CONNECT, (DWORD_PTR)&dwContext);
    if(hUrl == NULL) return 0;
    InternetQueryDataAvailable(hUrl, &dwFileSize, 0, (DWORD_PTR)&dwContext);
    pFile = (char*)malloc(dwFileSize+1);
    memset(pFile, 0, dwFileSize);
    InternetReadFile(hUrl, pFile, dwFileSize, &dwByteRead);
    pFile[dwByteRead] = 0;
    InternetCloseHandle(hUrl);
    InternetCloseHandle(hSession);
    a+ et merci quand meme

Discussions similaires

  1. Socket, recv et select qui ne marche pas
    Par Zapan dans le forum Réseau
    Réponses: 18
    Dernier message: 30/06/2006, 20h19
  2. [SWING] KeyListener qui ne marche pas
    Par kindool dans le forum AWT/Swing
    Réponses: 2
    Dernier message: 10/01/2005, 19h04
  3. Iptables configuration qui ne marche pas....
    Par The_Nail dans le forum Sécurité
    Réponses: 7
    Dernier message: 03/02/2004, 14h27
  4. Réponses: 3
    Dernier message: 08/09/2003, 15h06
  5. Réponses: 9
    Dernier message: 07/05/2003, 12h57

Partager

Partager
  • Envoyer la discussion sur Viadeo
  • Envoyer la discussion sur Twitter
  • Envoyer la discussion sur Google
  • Envoyer la discussion sur Facebook
  • Envoyer la discussion sur Digg
  • Envoyer la discussion sur Delicious
  • Envoyer la discussion sur MySpace
  • Envoyer la discussion sur Yahoo