<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0"><channel><title><![CDATA[GIF mit dem BCB herunterladen]]></title><description><![CDATA[<p>Hey @all,</p>
<p>und zwar habe ich folgendes Problem, ich will mir ein gif mittels dem BCB herunterladen, jedoch schreibt er mir zum Teil lauter müll in die datei, hier mal der Source:</p>
<pre><code class="language-cpp">void __fastcall TForm1::ClientSocket1Connect(TObject *Sender, TCustomWinSocket *Socket) {
   fstream file(this-&gt;filename.c_str(), ios::out | ios::binary);
   AnsiString buf;
   buf.cat_sprintf(&quot;GET http://%s/%s/%s HTTP/1.1 \n\n&quot;, this-&gt;server.c_str(),
                                                        this-&gt;server_path.c_str(),
                                                        this-&gt;filename.c_str()); //GET command for html transfer
//   buf+=(&quot; nrnr&quot;);     //required as end transfer tag
   Application-&gt;MessageBoxA(buf.c_str(), &quot;INFORMATION&quot;, MB_OK);

   // Neues TWinSocketStream mit einem Timeout von ca. 10000 sec.
   TWinSocketStream* wnscktstrmMain = new TWinSocketStream(Socket, 10000);
    if(wnscktstrmMain-&gt;Write(buf.c_str(),buf.Length())){ //if write succeeded, read from stream
      int i=1;
      char point[LENGTH]; // Deklariere buffer
      unsigned int file_length = 0;
      unsigned int max_file_length = LENGTH;  // Nur temporärer wert, kann auch anders lauten nur nicht den seleben wert wie file_length, da er sonst nicht downloaded
      memset(point, 0, LENGTH);// Initialisiere buffer
      if(wnscktstrmMain-&gt;Read(point,LENGTH)){
         point[LENGTH]='\0';
         StatusBar1-&gt;SimpleText=&quot;Success&quot;;
         buf=point;
/*         RichEdit1-&gt;Text=Memo1-&gt;Text+buf;
         Memo1-&gt;Text=Memo1-&gt;Text+buf;*/
//         lblCount-&gt;Caption=(lblCount-&gt;Caption.ToInt()+1); //incrementing line counter
         int j=0;
            bool do_write = false;
         while(file_length &lt;= max_file_length) {
/*           if(file_length &gt; 19000) {
           AnsiString t;
           t.cat_sprintf(&quot;%d == %d&quot;, file_length, max_file_length);
           Application-&gt;MessageBoxA(t.c_str(), &quot;&quot;, MB_OK);
           }*/
//         while(i&gt;0&amp;&amp;i&lt;200){
//            lblCount-&gt;Caption=(lblCount-&gt;Caption.ToInt()+1); //incrementing line counter
            wnscktstrmMain-&gt;Read(point,LENGTH);             //reading from stream
            buf=point;
            int p=0;
//            while(i!=0&amp;&amp;p&gt;=0&amp;&amp;p&lt;10){    //p is the # of lines to be
            while(i!=0&amp;&amp;p&gt;=0&amp;&amp;p&lt;1){    //p is the # of lines to be
//             Application-&gt;MessageBoxA(point, &quot;POINT&quot;, MB_OK);
              string buffer = buf.c_str();
//              Application-&gt;MessageBoxA(buf.c_str(), &quot;LINES&quot;, MB_OK);
              if(do_write) {
                file_length += buffer.length();
                file &lt;&lt; point;
              }
              if(!do_write) {
                if(buffer == &quot;\r\n&quot;)
                  do_write = true;
                else if(buffer == &quot;\n&quot;)
                  do_write = true;
                else if(buffer == &quot;\r&quot;)
                  do_write = true;
                else if(buffer.length() == 2)
                  do_write = true;
                else if(buffer.find(&quot;GIF&quot;) != string::npos) {
                  int pos = buffer.find(&quot;GIF&quot;);
                  //file &lt;&lt; buffer.substr(buffer.find(&quot;GIF&quot;));
//                  for(int i=pos; i&lt;LENGTH; i++)
                  for(int jj=pos; jj&lt;80; jj++) {
                    file &lt;&lt; point[jj];
                  }
                  file_length += buffer.substr(buffer.find(&quot;GIF&quot;)).length();
                  do_write = true;
                }

                if(buffer.find(&quot;Content&quot;) != string::npos) {
                  string content = buffer.substr(buffer.find(&quot;Content&quot;));
                  content = content.substr(content.find(&quot;:&quot;)+1);
                  content = content.substr(0, content.find(&quot;\n&quot;));

                  while(content.find(&quot; &quot;) != string::npos)
                    content.replace(content.find(&quot; &quot;), 1, &quot;&quot;);
//                  clrStr(content);
                  Memo1-&gt;Lines-&gt;Add(&quot;=====================================&quot;);
                  Memo1-&gt;Lines-&gt;Add(content.c_str());
                  Memo1-&gt;Lines-&gt;Add(&quot;=====================================&quot;);
                  stringstream s;
                  s &lt;&lt; content;
                  s &gt;&gt; max_file_length;
                }
              }
             p++;
           }

           if(i!=0){
//                 Memo1-&gt;Text=Memo1-&gt;Text+buf;  //add text as normal
                i++;
            }
         }
/*         if(i==((20))){
            Memo1-&gt;Lines-&gt;Add(&quot;&quot;);
            Memo1-&gt;Lines-&gt;Add(&quot;&quot;);
            Memo1-&gt;Lines-&gt;Add(&quot;*** Max Lines Reached! ***&quot;);
            Memo1-&gt;Lines-&gt;Add(&quot;&quot;);
         }
         Memo1-&gt;Lines-&gt;Add(&quot;----------------------------&quot;);*/
      }
      else
         ShowMessage(&quot;No reply&quot;);
   }
   else{
      ShowMessage(&quot;Connection timed out&quot;);

   }
   delete wnscktstrmMain;                                    //important
}
</code></pre>
<p>Könnte mir da bitte jemand weiterhelfen, und mir sagen was ich falsch mache?<br />
Vielen Dank im Voraus</p>
<p>Lg freeze</p>
]]></description><link>https://www.c-plusplus.net/forum/topic/93490/gif-mit-dem-bcb-herunterladen</link><generator>RSS for Node</generator><lastBuildDate>Wed, 08 Jul 2026 19:31:06 GMT</lastBuildDate><atom:link href="https://www.c-plusplus.net/forum/topic/93490.rss" rel="self" type="application/rss+xml"/><pubDate>Mon, 29 Nov 2004 21:14:15 GMT</pubDate><ttl>60</ttl><item><title><![CDATA[Reply to GIF mit dem BCB herunterladen on Mon, 29 Nov 2004 21:14:15 GMT]]></title><description><![CDATA[<p>Hey @all,</p>
<p>und zwar habe ich folgendes Problem, ich will mir ein gif mittels dem BCB herunterladen, jedoch schreibt er mir zum Teil lauter müll in die datei, hier mal der Source:</p>
<pre><code class="language-cpp">void __fastcall TForm1::ClientSocket1Connect(TObject *Sender, TCustomWinSocket *Socket) {
   fstream file(this-&gt;filename.c_str(), ios::out | ios::binary);
   AnsiString buf;
   buf.cat_sprintf(&quot;GET http://%s/%s/%s HTTP/1.1 \n\n&quot;, this-&gt;server.c_str(),
                                                        this-&gt;server_path.c_str(),
                                                        this-&gt;filename.c_str()); //GET command for html transfer
//   buf+=(&quot; nrnr&quot;);     //required as end transfer tag
   Application-&gt;MessageBoxA(buf.c_str(), &quot;INFORMATION&quot;, MB_OK);

   // Neues TWinSocketStream mit einem Timeout von ca. 10000 sec.
   TWinSocketStream* wnscktstrmMain = new TWinSocketStream(Socket, 10000);
    if(wnscktstrmMain-&gt;Write(buf.c_str(),buf.Length())){ //if write succeeded, read from stream
      int i=1;
      char point[LENGTH]; // Deklariere buffer
      unsigned int file_length = 0;
      unsigned int max_file_length = LENGTH;  // Nur temporärer wert, kann auch anders lauten nur nicht den seleben wert wie file_length, da er sonst nicht downloaded
      memset(point, 0, LENGTH);// Initialisiere buffer
      if(wnscktstrmMain-&gt;Read(point,LENGTH)){
         point[LENGTH]='\0';
         StatusBar1-&gt;SimpleText=&quot;Success&quot;;
         buf=point;
/*         RichEdit1-&gt;Text=Memo1-&gt;Text+buf;
         Memo1-&gt;Text=Memo1-&gt;Text+buf;*/
//         lblCount-&gt;Caption=(lblCount-&gt;Caption.ToInt()+1); //incrementing line counter
         int j=0;
            bool do_write = false;
         while(file_length &lt;= max_file_length) {
/*           if(file_length &gt; 19000) {
           AnsiString t;
           t.cat_sprintf(&quot;%d == %d&quot;, file_length, max_file_length);
           Application-&gt;MessageBoxA(t.c_str(), &quot;&quot;, MB_OK);
           }*/
//         while(i&gt;0&amp;&amp;i&lt;200){
//            lblCount-&gt;Caption=(lblCount-&gt;Caption.ToInt()+1); //incrementing line counter
            wnscktstrmMain-&gt;Read(point,LENGTH);             //reading from stream
            buf=point;
            int p=0;
//            while(i!=0&amp;&amp;p&gt;=0&amp;&amp;p&lt;10){    //p is the # of lines to be
            while(i!=0&amp;&amp;p&gt;=0&amp;&amp;p&lt;1){    //p is the # of lines to be
//             Application-&gt;MessageBoxA(point, &quot;POINT&quot;, MB_OK);
              string buffer = buf.c_str();
//              Application-&gt;MessageBoxA(buf.c_str(), &quot;LINES&quot;, MB_OK);
              if(do_write) {
                file_length += buffer.length();
                file &lt;&lt; point;
              }
              if(!do_write) {
                if(buffer == &quot;\r\n&quot;)
                  do_write = true;
                else if(buffer == &quot;\n&quot;)
                  do_write = true;
                else if(buffer == &quot;\r&quot;)
                  do_write = true;
                else if(buffer.length() == 2)
                  do_write = true;
                else if(buffer.find(&quot;GIF&quot;) != string::npos) {
                  int pos = buffer.find(&quot;GIF&quot;);
                  //file &lt;&lt; buffer.substr(buffer.find(&quot;GIF&quot;));
//                  for(int i=pos; i&lt;LENGTH; i++)
                  for(int jj=pos; jj&lt;80; jj++) {
                    file &lt;&lt; point[jj];
                  }
                  file_length += buffer.substr(buffer.find(&quot;GIF&quot;)).length();
                  do_write = true;
                }

                if(buffer.find(&quot;Content&quot;) != string::npos) {
                  string content = buffer.substr(buffer.find(&quot;Content&quot;));
                  content = content.substr(content.find(&quot;:&quot;)+1);
                  content = content.substr(0, content.find(&quot;\n&quot;));

                  while(content.find(&quot; &quot;) != string::npos)
                    content.replace(content.find(&quot; &quot;), 1, &quot;&quot;);
//                  clrStr(content);
                  Memo1-&gt;Lines-&gt;Add(&quot;=====================================&quot;);
                  Memo1-&gt;Lines-&gt;Add(content.c_str());
                  Memo1-&gt;Lines-&gt;Add(&quot;=====================================&quot;);
                  stringstream s;
                  s &lt;&lt; content;
                  s &gt;&gt; max_file_length;
                }
              }
             p++;
           }

           if(i!=0){
//                 Memo1-&gt;Text=Memo1-&gt;Text+buf;  //add text as normal
                i++;
            }
         }
/*         if(i==((20))){
            Memo1-&gt;Lines-&gt;Add(&quot;&quot;);
            Memo1-&gt;Lines-&gt;Add(&quot;&quot;);
            Memo1-&gt;Lines-&gt;Add(&quot;*** Max Lines Reached! ***&quot;);
            Memo1-&gt;Lines-&gt;Add(&quot;&quot;);
         }
         Memo1-&gt;Lines-&gt;Add(&quot;----------------------------&quot;);*/
      }
      else
         ShowMessage(&quot;No reply&quot;);
   }
   else{
      ShowMessage(&quot;Connection timed out&quot;);

   }
   delete wnscktstrmMain;                                    //important
}
</code></pre>
<p>Könnte mir da bitte jemand weiterhelfen, und mir sagen was ich falsch mache?<br />
Vielen Dank im Voraus</p>
<p>Lg freeze</p>
]]></description><link>https://www.c-plusplus.net/forum/post/662292</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/662292</guid><dc:creator><![CDATA[_freeze_]]></dc:creator><pubDate>Mon, 29 Nov 2004 21:14:15 GMT</pubDate></item><item><title><![CDATA[Reply to GIF mit dem BCB herunterladen on Mon, 29 Nov 2004 21:32:52 GMT]]></title><description><![CDATA[<p>Ist das eine Fingerübung zum Umgang mit Sockets, oder warum benutzt du keine HTTP-Komponente?</p>
]]></description><link>https://www.c-plusplus.net/forum/post/662315</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/662315</guid><dc:creator><![CDATA[Jansen]]></dc:creator><pubDate>Mon, 29 Nov 2004 21:32:52 GMT</pubDate></item><item><title><![CDATA[Reply to GIF mit dem BCB herunterladen on Tue, 30 Nov 2004 07:21:34 GMT]]></title><description><![CDATA[<p>Ich verwende BCB Personal, soweit ich weiß gibt es da keine HTTP Komponente, und die Indy's habe ich nicht integrieren können. <img
      src="https://www.c-plusplus.net/forum/plugins/nodebb-plugin-emoji/emoji/emoji-one/1f61e.png?v=ab1pehoraso"
      class="not-responsive emoji emoji-emoji-one emoji--disappointed_face"
      title=":("
      alt="😞"
    /></p>
<p>Lg _freeze_</p>
<p>P.S.: Ich habe bei BCB Personal nur den Client-Socket und den Client-Server dabei</p>
]]></description><link>https://www.c-plusplus.net/forum/post/662467</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/662467</guid><dc:creator><![CDATA[_freeze_]]></dc:creator><pubDate>Tue, 30 Nov 2004 07:21:34 GMT</pubDate></item><item><title><![CDATA[Reply to GIF mit dem BCB herunterladen on Tue, 30 Nov 2004 21:17:38 GMT]]></title><description><![CDATA[<p>Ich will es wirklich mit TClientSocket und nicht den Indy-Komponenten machen</p>
<p>Kann mir bitte jemand helfen, das Projekt soll bis 20 Dezember 2004 fertig werden (Geburtstagsgeschenk) ich hänge wirklich nur mehr bei dieser Sache.</p>
<p>Vielen herzlichen Dank im Voraus</p>
<p>Lg _freeze_</p>
]]></description><link>https://www.c-plusplus.net/forum/post/663220</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/663220</guid><dc:creator><![CDATA[_freeze_]]></dc:creator><pubDate>Tue, 30 Nov 2004 21:17:38 GMT</pubDate></item></channel></rss>