i want to send a file from client to server through socket . yes it sends a file but the received file in the server is not full or complete like the original one.
So the test file originally has "this is a test" in it, and the received file has "this"
yes it's only 4 letters
i tried to change the original one becomes "MyMomGoesToTheMarket" and received file has "MyMo" . still 4 letters which is not what i expect.
rbuffer = new char[Size];
myfile.read(rbuffer, Size);
//send(clientsock, rbuffer, Size, 0);
int j = send(clientsock, rbuffer, Size, NULL); //send to server
if (j == -1){
cout << "Error sending file to server :(" << endl;
}else {
cout << " sending file to server succeed" << endl;
}
Please use code tags to make your code easier to read and respond to.
This is actually a little above my skill but I'm going to guess at something I'm not sure about and you can test to see if it is right or wrong.
I don't understand is how the server is supposed to know what the file/buffer size should be ? Perhaps that is the code to write the file after it's received.
I'm guessing it's a problem with your buffers. What I'm not sure about is the space in the name "new char" below. Should there be a space ?
1 2
char *rbuffer;
rbuffer = newchar[Size];
My advice is to put in some print/cout statements and display on the screen all the things you are assuming are working but maybe haven't tested.