I am writing a UDP flooder program in an attempt to get better with socket programming. Everything has gone well so far except for some reason this piece of code:
"int Packets;
cin >> Packets;"
is skipped when I run the program.
I have also tried using getline(cin, Packets) but for some reason my compiler fails to recognize it.
I am using Microsoft Visual C++ 2010 express
int _tmain(int argc, _TCHAR* argv[])
{
int OutSocket;
OutSocket = socket(AF_INET, SOCK_DGRAM, IPPROTO_UDP); // define a socket and get its address
cout << "Please enter the IP address of the target: ";
sockaddr_in ForeignAddress; // define an address structure
cin >> ForeignAddress.sin_addr.S_un.S_addr; // get the ip address from the user
//cout << "Please enter the port you want to attack: ";
//cin >> ForeignAddress.sin_port; // get the port from the user
ForeignAddress.sin_port = 80;
ForeignAddress.sin_family = AF_INET; //set the family (this value is almost always the same)
sockaddr *AddressPointer; // define a pointer to the address struct
AddressPointer = (sockaddr*)&ForeignAddress; // cast the sockaddr_in as a sockaddr pointer (this is necessary to please the sento function)
char * BufferPTR = new char [5]; // buffer to send
BufferPTR = "hello"; //set the buffer contents
int ForeignAddressLength;
ForeignAddressLength = sizeof(ForeignAddress.sin_addr.S_un.S_addr);
cout << "please enter the number of packets you would like to send: ";
int Packets;
cin >> Packets;