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 26 27 28 29 30 31 32 33 34 35 36
| int main(int argc, char *argv[])
{
char ip[16];
char reply[1024];
char request[1024];
int port;
int nbsend,nbreceive;
SOCKET Socket;
SOCKADDR_IN infodest;
printf("Entrez Ip \n\n");
scanf("%s",ip);
printf("Entrez Port \n\n");
scanf("%d",&port);
initw();
create_socket(Socket);
if( connection_tcp(ip,port,Socket,infodest) )printf("\nConnecte au serveur %s sur le port %d\n",ip,port);
// ENVOIT D'UNE REQUETE //
strcpy(request,"GET / HTTP/1.1\r\nUser-Agent: Mozilla/5.0 (Windows; U; Windows NT 5.1; fr; rv:1.9.0.1) Gecko/2008070208 Firefox/3.0.1\r\nAccept: text/html\r\nAccept-Language: fr,fr-fr;q=0.8,en-us;q=0.5,en;q=0.3\r\n");
nbsend=send(Socket,request,strlen(request),0);
nbreceive=recv(Socket,reply,1024,0);
system("pause");
printf("%s",reply);
} |
Partager