473,322 Members | 1,259 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,322 software developers and data experts.

iostream::read function

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?
Jul 19 '05 #1
0 6952

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

19
by: ernst.stiegler | last post by:
Hello, I just want to read a whole line from a console input. What I don't understand is that I always have to press ENTER twice in order to see the line I've entered. Here's my code : ...
3
by: Amadeus W.M. | last post by:
Does iostream::read() throw any exception already, or do I have to check with iostream::fail()? Like this: fstream IN("myfile", ios::in | ios::binary); char buf; IN.read(buf, 100);...
20
by: Mark | last post by:
I am using gnu g++ version 3.3.2, trying a simple test to read in and then write out a large (100,000 line) text file ########################################## CSTDIO VERSION TO READ/WRITE...
0
by: Garrett Kajmowicz | last post by:
I have two implementations of stringstream and they both handle interleaved reads and writes differently. I was hoping that you might be able to shed some light as to the "correct" operation, and...
0
by: Greg Stoch | last post by:
Hi, How to check if the stream is opened in binary mode? Suppose, we are about creating "bool is_binary(iostream &)" function for such an assertion, working like this: .... ofstream os...
3
by: Chad E. Dollins | last post by:
I've got some trick input that I need help reading. I am using iostream because it is still a holiday weekend and I'm not trying to stress, but I have some input that looks like this. 2 ...
3
by: garyatusa | last post by:
Hi, there, I need to put a bunch of data to an iostream, or a buffer sequencially for each object, and write them to a file in specific sequence. I couldn't find any helpful information how to...
4
by: Herman.Schultz | last post by:
Hi, How can I use iostream library in c++ to copy a file from i th byte to an output file? Thank you.
3
by: Joy Maitland | last post by:
how to use <iostreamto read a file to a const BYTE array? const BYTE *pbBinary
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
1
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.