So if you want to send a text file to some you would use:
Client:
char* rbuffer; //will save file content here
ifstream file;
file.open(filepath, ios::in | ios::binary | ios::ate); //open file
if(file.is_open()){
file.seekg(0, ios::end);
size = file.tellg(); //file size!
cout << "The file size is " << size << " Bytes" << endl;
file.seekg(0, ios::beg); //sets location back to beginning of file
rbuffer = new char[size];
file.read(rbuffer, size); //write file to buffer
clock_t ustart, uend; //timer
ustart=clock();
int j = send(sock, rbuffer, size, NULL); //send file to server
if (j == -1){
cout << "Error uploading file to server :(" << endl;
}
Server:
char* rbuffer;
rbuffer = new char[5000]; //will write message to this buffer
clock_t ustart, uend;
ustart = clock();
int k = recv(client_socket, rbuffer, sizeof(rbuffer), NULL);
if (k < 0){
cout << "Error uploading file" << endl;
}
cout << "File is being uploaded..." << endl;
cout << "File received!" << endl;
But how can I send a .exe file over the internet?