<?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[OVERLAPPED]]></title><description><![CDATA[<p>Tach,</p>
<p>Ich hab mich heute etwas mit ReadFile auseinandergesetzt und im Forum auch das ein oder andere gefunden zum Thema. Trotzdem noch eine Frage:</p>
<p>Was bezweckt der Parameter OVERLAPPED und wie implementiere ich eine OVERLAPPED-Abfrage (is garnicht so einfach, wie ich finde...)</p>
<p>Ich bin Newbie in C/C++ und im Forum hier scheint der ein oder andere Ahnung vom Thema zu haben...</p>
<p>Danke jetzt schon...</p>
]]></description><link>https://www.c-plusplus.net/forum/topic/105326/overlapped</link><generator>RSS for Node</generator><lastBuildDate>Thu, 02 Jul 2026 06:17:33 GMT</lastBuildDate><atom:link href="https://www.c-plusplus.net/forum/topic/105326.rss" rel="self" type="application/rss+xml"/><pubDate>Tue, 29 Mar 2005 11:58:30 GMT</pubDate><ttl>60</ttl><item><title><![CDATA[Reply to OVERLAPPED on Tue, 29 Mar 2005 11:58:30 GMT]]></title><description><![CDATA[<p>Tach,</p>
<p>Ich hab mich heute etwas mit ReadFile auseinandergesetzt und im Forum auch das ein oder andere gefunden zum Thema. Trotzdem noch eine Frage:</p>
<p>Was bezweckt der Parameter OVERLAPPED und wie implementiere ich eine OVERLAPPED-Abfrage (is garnicht so einfach, wie ich finde...)</p>
<p>Ich bin Newbie in C/C++ und im Forum hier scheint der ein oder andere Ahnung vom Thema zu haben...</p>
<p>Danke jetzt schon...</p>
]]></description><link>https://www.c-plusplus.net/forum/post/754852</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/754852</guid><dc:creator><![CDATA[Der Gast]]></dc:creator><pubDate>Tue, 29 Mar 2005 11:58:30 GMT</pubDate></item><item><title><![CDATA[Reply to OVERLAPPED on Tue, 29 Mar 2005 12:07:35 GMT]]></title><description><![CDATA[<p>einfaches bsp<br />
<a href="http://msdn.microsoft.com/library/default.asp?url=/library/en-us/fileio/base/readfile.asp" rel="nofollow">http://msdn.microsoft.com/library/default.asp?url=/library/en-us/fileio/base/readfile.asp</a></p>
<p>mit pipes<br />
<a href="http://msdn.microsoft.com/library/default.asp?url=/library/en-us/ipc/base/named_pipe_server_using_overlapped_i_o.asp" rel="nofollow">http://msdn.microsoft.com/library/default.asp?url=/library/en-us/ipc/base/named_pipe_server_using_overlapped_i_o.asp</a></p>
<p>sollte alle fragen beantworten</p>
]]></description><link>https://www.c-plusplus.net/forum/post/754860</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/754860</guid><dc:creator><![CDATA[miller_m]]></dc:creator><pubDate>Tue, 29 Mar 2005 12:07:35 GMT</pubDate></item><item><title><![CDATA[Reply to OVERLAPPED on Tue, 29 Mar 2005 12:10:19 GMT]]></title><description><![CDATA[<p>damit kannste readfile/writefile usw. im hintergrund ablaufen lassen. wenn die was zu melden haben (datei geschrieben oder so), bekommste ein event-objekt gesetzt. guckst du: <a href="http://msdn.microsoft.com/library/default.asp?url=/library/en-us/dllproc/base/synchronization_and_overlapped_input_and_output.asp" rel="nofollow">http://msdn.microsoft.com/library/default.asp?url=/library/en-us/dllproc/base/synchronization_and_overlapped_input_and_output.asp</a></p>
]]></description><link>https://www.c-plusplus.net/forum/post/754865</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/754865</guid><dc:creator><![CDATA[net 0]]></dc:creator><pubDate>Tue, 29 Mar 2005 12:10:19 GMT</pubDate></item><item><title><![CDATA[Reply to OVERLAPPED on Tue, 29 Mar 2005 12:50:09 GMT]]></title><description><![CDATA[<p>Das war Fix... Danke für die Antworten...</p>
]]></description><link>https://www.c-plusplus.net/forum/post/754898</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/754898</guid><dc:creator><![CDATA[Der Gast]]></dc:creator><pubDate>Tue, 29 Mar 2005 12:50:09 GMT</pubDate></item><item><title><![CDATA[Reply to OVERLAPPED on Thu, 31 Mar 2005 19:21:04 GMT]]></title><description><![CDATA[<p>Guten Tach,</p>
<p>Ich bin euern Tipps, munter nachgegengen und hab mir was Nettes gebastelt (hat noch 'n paar Zeilen drin, die etwas blödsinnig daher kommen, die währen dann für Testzwecke):</p>
<pre><code class="language-cpp">CHAR handleCOMPort::getIO()
{
  char inBuffer;
  OVERLAPPED gOverlapped;
  DWORD lpEvtMask;
  DWORD nBytesRead;
  DWORD dwError;
  BOOL bResult;

  memset(&amp;gOverlapped,0,sizeof(gOverlapped));
  // set up overlapped structure fields
  // gOverlapped.Offset     = 0; 
  // gOverlapped.OffsetHigh = 0; 
  gOverlapped.hEvent     = CreateEvent(NULL, TRUE, FALSE, NULL);

  // verify that sizeof(inBuffer &lt;= nBytestoRead)

  SetCommMask(hCom, EV_RXCHAR | EV_RXFLAG);

  //PurgeComm(hCom, PURGE_TXABORT | PURGE_RXABORT | PURGE_TXCLEAR | PURGE_RXCLEAR);

  while(TRUE)
  {
    if(TRUE)//(WaitCommEvent(hCom, &amp;lpEvtMask, &amp;gOverlapped))
    {
      if(!ReadFile(hCom, &amp;inBuffer, 1, &amp;nBytesRead, &amp;gOverlapped)) 
      { 
        // deal with the error code 
        switch(dwError = GetLastError()) 
        { 
          case ERROR_HANDLE_EOF: 
          { 
            // we have reached the end of the file 
            // during the call to ReadFile 
            // code to handle that 
          } 
          case ERROR_IO_PENDING: 
          { 
            // asynchronous i/o is still in progress 
            // do something else for a while 
            //GoDoSomethingElse() ; 
            // check on the results of the asynchronous read  
            // if there was a problem ... 
            if (!GetOverlappedResult(hCom, &amp;gOverlapped, &amp;nBytesRead, TRUE)) 
            { 
              printf(&quot;Error&quot;);
              // deal with the error code 
              switch (dwError = GetLastError()) 
              { 
                case ERROR_HANDLE_EOF: 
                { 
                  printf(&quot;ERROR EOF\n&quot;);
                  // we have reached the end of
                  // the file during asynchronous
                  // operation
                  break;
                } 
                case ERROR_IO_INCOMPLETE: 
                { 
                  printf(&quot;IO Incomplete\n&quot;);
                  // we have reached the end of
                  // the file during asynchronous
                  // operation
                  break;
                } 
                default:
                {
                  printf(&quot;ERROR DEFAULT\n&quot;);
                  break;
                }
                // deal with other error cases 
              }   //end switch (dwError = GetLastError()) 
            } 
          } // end case 
          // deal with other error cases, such as the default 
        } // end switch (dwError = GetLastError()) 
      } // end if 
      else
      {
        printf(&quot;CHAR: %c\n&quot;, inBuffer);
        return inBuffer;
      }
      break;
    }
    else
    {
      printf(&quot;TEST&quot;);
    }
  }
  //printf(&quot;CHAR: %c\n&quot;, inBuffer);
  return FALSE;
}
</code></pre>
<p>Aufgerufen soll das ganze aus einem Thread heraus werden, mit ner kleinen Schlaufe, bei mir zum testen wie folgt:</p>
<pre><code class="language-cpp">for(int i = 0; i &lt; 200; i++){
  char x;
  if(x = COMPort1.getIO()) 
    i=i;//printf(&quot;port 1 captured: %c\n&quot;, &amp;x);
  else
    printf(&quot;%i could not capture port 1\n&quot;, i);
  Sleep(10); //ohne sleep hab ich n bisschen viele fehler
  }
</code></pre>
<p>Die Idee ich aus 'm MSDN abgekupfert, wie unschwer zu erkennen ist... Das hat aber nicht auf anhieb geklappt daher das eigene &quot;Gebastel&quot;.</p>
<p>Ziel ist es, das mir die Funktion bei jedem Aufruf das nächste Zeichen vom Port her liefert, so das ich win einer Endlosschlaufe in nem Thread andauernd den Input lesen und in ne Liste schreiben kann...</p>
<p>Ein besondere Dorn im Auge ist hier vor allem</p>
<pre><code class="language-cpp">GetOverlappedResult(hCom, &amp;gOverlapped, &amp;nBytesRead, TRUE)
</code></pre>
<p>, mit betonung auf das TRUE;</p>
<p>Kommen nächmlich keine Daten an, hängen wir!</p>
<p>Ich bitte dringenst um Hilfe, langsam hab' ich etwas Zeitdruck <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>Besten Dank<br />
Euer Gast</p>
]]></description><link>https://www.c-plusplus.net/forum/post/756746</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/756746</guid><dc:creator><![CDATA[Der Gast]]></dc:creator><pubDate>Thu, 31 Mar 2005 19:21:04 GMT</pubDate></item><item><title><![CDATA[Reply to OVERLAPPED on Thu, 31 Mar 2005 19:40:07 GMT]]></title><description><![CDATA[<p>du hast es dir schon selbst beantwortet <img
      src="https://www.c-plusplus.net/forum/plugins/nodebb-plugin-emoji/emoji/emoji-one/1f609.png?v=ab1pehoraso"
      class="not-responsive emoji emoji-emoji-one emoji--winking_face"
      title=";)"
      alt="😉"
    /><br />
eben statt TRUE FALSE nehmen und dann noch auf ERROR_IO_INCOMPLETE reagieren.<br />
guckst du: <a href="http://msdn.microsoft.com/library/default.asp?url=/library/en-us/dllproc/base/getoverlappedresult.asp" rel="nofollow">http://msdn.microsoft.com/library/default.asp?url=/library/en-us/dllproc/base/getoverlappedresult.asp</a></p>
]]></description><link>https://www.c-plusplus.net/forum/post/756764</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/756764</guid><dc:creator><![CDATA[net 0]]></dc:creator><pubDate>Thu, 31 Mar 2005 19:40:07 GMT</pubDate></item><item><title><![CDATA[Reply to OVERLAPPED on Thu, 31 Mar 2005 20:10:00 GMT]]></title><description><![CDATA[<p>net schrieb:</p>
<blockquote>
<p>eben statt TRUE FALSE nehmen und dann noch auf ERROR_IO_INCOMPLETE reagieren.</p>
</blockquote>
<p>Nun Ja...</p>
<p>Das hab ich mir selbst auch schon überlegt... aber wie reagiere ich am besten auf einen ERROR_IO_INCOMPLETE?</p>
]]></description><link>https://www.c-plusplus.net/forum/post/756818</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/756818</guid><dc:creator><![CDATA[Der Gast]]></dc:creator><pubDate>Thu, 31 Mar 2005 20:10:00 GMT</pubDate></item><item><title><![CDATA[Reply to OVERLAPPED on Thu, 31 Mar 2005 20:13:56 GMT]]></title><description><![CDATA[<p>Der Gast schrieb:</p>
<blockquote>
<p>Das hab ich mir selbst auch schon überlegt... aber wie reagiere ich am besten auf einen ERROR_IO_INCOMPLETE?</p>
</blockquote>
<p>den entsprechenden case-zweig haste ja schon in deinem code drin. du könntest z.b. die funktion umbauen, dass die kein 'char' sondern ein 'int' zurückgibt und bei ERROR_IO_INCOMPLETE gibste einfach '-1' zurück (das sagt dem aufrufer dass nix empfangen wurde.</p>
]]></description><link>https://www.c-plusplus.net/forum/post/756820</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/756820</guid><dc:creator><![CDATA[net 0]]></dc:creator><pubDate>Thu, 31 Mar 2005 20:13:56 GMT</pubDate></item><item><title><![CDATA[Reply to OVERLAPPED on Thu, 31 Mar 2005 20:29:10 GMT]]></title><description><![CDATA[<p>Hab ich schon Probier, allerding hab ich mir einfach &quot;a&quot;'s zugesendet und im besagten case dann &quot;z&quot; als rückgabewert der funktion gegeben:</p>
<pre><code class="language-cpp">case ERROR_IO_INCOMPLETE: 
{ 
  inBuffer='z';
  return inBuffer;
  //printf(&quot;IO Incomplete\n&quot;);

  //break;
}
</code></pre>
<p>Mit folgendem erfolg:</p>
<p>Fange ich mit dem Senden von Daten (mittels AccesPort) vor dem öffnen des Porten an, krieg ich nur &quot;z&quot;'s</p>
<p>Schicke ich die daten erst auf dem Port, wen ich am anderen ende mein &quot;Program&quot; bereits gestartet habe, also schon einige &quot;z&quot;'s enpfangen habe, schmiert mir das ganze ab und windows fragt mich, ob ich einen fehlerreport senden will... <img
      src="https://www.c-plusplus.net/forum/plugins/nodebb-plugin-emoji/emoji/emoji-one/1f621.png?v=ab1pehoraso"
      class="not-responsive emoji emoji-emoji-one emoji--pouting_face"
      title=":rage:"
      alt="😡"
    /></p>
<p>Ich will nicht mehr zu viel Code posten, daher:</p>
<blockquote>
<p>&gt; Der ganze mist:</p>
</blockquote>
<p>[url]<a href="http://free.pages.at/d_menet/cplusplus/main.cpp" rel="nofollow">http://free.pages.at/d_menet/cplusplus/main.cpp</a> [/url]</p>
]]></description><link>https://www.c-plusplus.net/forum/post/756833</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/756833</guid><dc:creator><![CDATA[Der Gast]]></dc:creator><pubDate>Thu, 31 Mar 2005 20:29:10 GMT</pubDate></item><item><title><![CDATA[Reply to OVERLAPPED on Thu, 31 Mar 2005 20:32:56 GMT]]></title><description><![CDATA[<p>Der Gast schrieb:</p>
<blockquote>
<p>Schicke ich die daten erst auf dem Port, wen ich am anderen ende mein &quot;Program&quot; bereits gestartet habe, also schon einige &quot;z&quot;'s enpfangen habe, schmiert mir das ganze ab und windows fragt mich, ob ich einen fehlerreport senden will... <img
      src="https://www.c-plusplus.net/forum/plugins/nodebb-plugin-emoji/emoji/emoji-one/1f621.png?v=ab1pehoraso"
      class="not-responsive emoji emoji-emoji-one emoji--pouting_face"
      title=":rage:"
      alt="😡"
    /></p>
</blockquote>
<p>das ist aber ein anderes problem. da musste wohl mit'm debugger ran...</p>
]]></description><link>https://www.c-plusplus.net/forum/post/756840</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/756840</guid><dc:creator><![CDATA[net 0]]></dc:creator><pubDate>Thu, 31 Mar 2005 20:32:56 GMT</pubDate></item></channel></rss>