iostream::read function

L

Lans Redmond

I have the following

ifstream in("abc.txt",ios::in)
char buff[8192];

if (!in)
{
cout << "error opening file" << endl;
}

while ( !in.eof())
{
in.read(buff,sizeof(buff));
int a = in.gcount();
int total += send (sock,buff,a,NULL);
}
in.close();
close(sock)

This is a windows program.
Now this is a simple read function that will read a file and devliver the
output through a socket. The in file is 50011 bytes. When this functions
ends my output is 48875bytes. I seem to be loosing bytes somewhere but cant
figure out where. When I look at the output it ending lines matches the
ending lines on the input, so it looks like I got the entire file. Any
ideas?
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,755
Messages
2,569,536
Members
45,009
Latest member
GidgetGamb

Latest Threads

Top