Voilà je rajoute mon code
Cette fois ci je veux obtenir la page de google.
j'ai ce que je demande à la première requête mais pas à la seconde
#include <sys/types.h>
#include <sys/socket.h>
#include <netinet/in.h>
#include <arpa/inet.h>
#include <unistd.h>
#include <netdb.h>
#include <stdio.h>
#include <stdlib.h>
#define INVALID_SOCKET -1
#define SOCKET_ERROR -1
#define closesocket(param) close(param)
typedef int SOCKET;
typedef struct sockaddr_in SOCKADDR_IN;
typedef struct sockaddr SOCKADDR;
char requete1[]="GET / HTTP/1.1\r\nHost: www.google.fr\r\nConnection:Keep-Alive\r\n\r\n";
char ch[2024];
int main()
{
SOCKET sock;
int ret = 0;
host = gethostbyname("www.google.fr");
sock = socket(AF_INET, SOCK_STREAM, 0);
if (sock == 0) printf("erreur ouverture socket"),exit(EXIT_FAILURE);
SOCKADDR_IN sin;
sin.sin_addr.s_addr = inet_addr(inet_ntoa( * (struct in_addr *)( host->h_addr_list[0]) ));
sin.sin_family = AF_INET;
sin.sin_port = htons(80);
ret = connect(sock, (SOCKADDR *)&sin, sizeof(sin) );
if (ret==0)
{
printf("Début de la Connexion au serveur \n");
send(sock,requete1,sizeof(requete1),0);
recv(sock,ch,sizeof(ch),0);
printf("Info recu :%s\n",ch);
memset(ch,0,sizeof(ch));
send(sock,requete1,sizeof(requete1),0);
recv(sock,ch,sizeof(ch),0);
printf("\n\nReponce recu :%s\n",ch);
}
closesocket(sock);
printf("Fin de la connexion au serveur\n");
return EXIT_SUCCESS;
}
Pouvez vous m'indiquer ce qui cloche merci