Hey guys,
I have the following function that I use to send binary data over the network:
Now, the problem with it is when it gets to the end of the file it tries to read in 10000 bytes (I think), but there aren't that many, and it ends up sending junk at the end. I need a way that I can see exactly how many bytes were read in so I can send.PHP Code:
bool CONNECTION::SendBinary()
{
char Buffer[10000];
// Open the file as binary
ifstream hFile (RealFile.c_str(), ios::binary);
while (!hFile.eof()) // Keep reading it in
{
hFile.read(Buffer, 10000);
int Y = send(SFD, Buffer, 1000, 0); // Send data as we read it
}
hFile.close(); // Close
return true;
}
So all I really want to know is, how can I check how many bytes an ifstream'd file read()'s. Thanks for any help