You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@poi.apache.org by Ramon F Herrera <ra...@patriot.net> on 2011/01/11 23:15:18 UTC

ASIO: What is the proper way to upload a LARGE file?

I have successfully been using this code to upload small stuff:

try {
   // open tcp connection
   tcp::iostream net_stream(strSubmitServer, "12345");

   // send file name
   net_stream <<  strFile << endl;

   // copy file
   char  ch;
   while ((ch = fgetc(f)) != EOF)
     net_stream << ch;

   } catch (std::exception& e) {
	std::cout << "Exception: " << e.what() << std::endl;
}

Needless to say, the code above is extremely slow/inefficient for bulky 
transfers.

Now I need to upload some large fails, and tried this:

   tcp::iostream net_stream(SERVER_ADDR, "12345");
   // send file name
   net_stream <<  IN_FILE << "\n";
   // send tags data size
   net_stream <<  count << "\n";
   // copy tags data
   net_stream.write((char *)data, count);  <<== app crashes here

I figured that TCP would break the delivery into packets...

TIA,

-Ramon




---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@poi.apache.org
For additional commands, e-mail: user-help@poi.apache.org


Re: ASIO: What is the proper way to upload a LARGE file?

Posted by Ramon F Herrera <ra...@patriot.net>.
It looks like I clicked on the wrong newsgroup... Small wonder I didn't 
get any answers.   :-/

-RFH

On 1/11/2011 4:15 PM, Ramon F Herrera wrote:
>
> I have successfully been using this code to upload small stuff:
>
> try {
> // open tcp connection
> tcp::iostream net_stream(strSubmitServer, "12345");
>
> // send file name
> net_stream << strFile << endl;
>
> // copy file
> char ch;
> while ((ch = fgetc(f)) != EOF)
> net_stream << ch;
>
> } catch (std::exception& e) {
> std::cout << "Exception: " << e.what() << std::endl;
> }
>
> Needless to say, the code above is extremely slow/inefficient for bulky
> transfers.
>
> Now I need to upload some large fails, and tried this:
>
> tcp::iostream net_stream(SERVER_ADDR, "12345");
> // send file name
> net_stream << IN_FILE << "\n";
> // send tags data size
> net_stream << count << "\n";
> // copy tags data
> net_stream.write((char *)data, count); <<== app crashes here
>
> I figured that TCP would break the delivery into packets...
>
> TIA,
>
> -Ramon



---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@poi.apache.org
For additional commands, e-mail: user-help@poi.apache.org