Boost logo

Boost Users :

From: Christopher Kohlhoff (chris_at_[hidden])
Date: 2007-06-12 19:16:13


Chris Fairles wrote:
> while (bytes_sent < filesize_) {
> //i test a file 21200678 bytes long. This tranfers anywhere from
> 21135097 to 21196000.
> bytes_sent += data_socket_.send(boost::asio::buffer(file.rdbuf(),
> std::min(size,filesize_-bytes_sent)));
>
> //this always transfers 21204202
> bytes_sent += data_socket_.send(boost::asio::buffer(file.rdbuf(), size));
>
> }

I don't see anything in this loop to consume the data from the ifstream.

> What am I doing wrong? Sometimes bytes_sent is exactly the file size,
> but the remote file size is slightly less. Maybe closing the socket
> stream too early? That sends an eof which the server responds to but
> it should arrive AFTER the data i would think...

I can't say what's wrong with your iostream code, but as send() and write_some()
can result in a "short send" (i.e. send fewer bytes than you ask it to) you
might like to use asio::write() instead.

Cheers,
Chris


Boost-users list run by williamkempf at hotmail.com, kalb at libertysoft.com, bjorn.karlsson at readsoft.com, gregod at cs.rpi.edu, wekempf at cox.net