Código
#include <stdio.h> #include <winsock.h> int main() { WSADATA wsa; SOCKET sock; char peticion[]="GET / HTTP/1.0\r\n\r\n"; char buffer[1024]; struct sockaddr_in dir; struct hostent *host; WSAStartup( MAKEWORD(1,1), &wsa); sock=socket( AF_INET, SOCK_STREAM, 0); host=gethostbyname( "localhost"); dir.sin_addr=*((struct in_addr *)host->h_addr); dir.sin_family=AF_INET; dir.sin_port=htons(80); if(connect( sock, (struct sockaddr *)&dir, sizeof(struct sockaddr))==-1) { return 1; } recv( sock, buffer, 1023, 0); closesocket( sock); return 0; }
Sa1uDoS