iostream::read function

Discussion in 'C++' started by Lans Redmond, Jun 26, 2003.

  1. Lans Redmond

    Lans Redmond Guest

    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?
     
    Lans Redmond, Jun 26, 2003
    #1
    1. Advertising

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

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. John Tiger
    Replies:
    10
    Views:
    5,666
  2. ai@work
    Replies:
    9
    Views:
    569
    Ron Natalie
    Dec 16, 2004
  3. S. Nurbe

    iostream + iostream.h

    S. Nurbe, Jan 14, 2005, in forum: C++
    Replies:
    7
    Views:
    805
    red floyd
    Jan 15, 2005
  4. red floyd
    Replies:
    3
    Views:
    557
    Dietmar Kuehl
    Mar 8, 2005
  5. Garrett Kajmowicz

    Interleaving iostream read and write

    Garrett Kajmowicz, Aug 14, 2005, in forum: C++
    Replies:
    0
    Views:
    472
    Garrett Kajmowicz
    Aug 14, 2005
Loading...

Share This Page