Article View: borland.public.cppbuilder.nativeapi
Article #4385Re: Named pipe conundrum
From: Remy Lebeau (TeamB)
Date: Tue, 31 Jan 2006 19:10
Date: Tue, 31 Jan 2006 19:10
36 lines
2633 bytes
2633 bytes
"Duane A." <none@nowhere.com> wrote in message news:43dfb314$1@newsgroups.borland.com... > I'm trying to debug a recalcitrant C++Builder 6 app and had the > brainstorm of writing a separate pipe server task to receive/ > log-to-file debug messages from it. Both programs would reside > on the same machine. An easier thing to do is to use the OutputDebugString() function instead. You can then use a third-party viewer, such as DebugView from http://www.sysinternals.com. > I blithely thought that incorporating the client side into the buggy > app would be a snap, but... I can only perform a single write into > the pipe, using WriteFile(...) before it seems that I never get another > I/O event signalling that the write was finished and the API is ready > for another message. After you call WriteFile(), DO NOT call GetLastError() in a loop! Calling ProcessMessages() can change the value that GetLastError() returns (since ProcessMessage() calls other API functons internally), and that value will have nothing to do with the I/O operation at all. Also, using GetLastError() to wait for an I/O operation to complete is the completely wrong approach to take anyway. If you take out the ProcessMessages() then GetLastError() would not change value at all, so you would end up in an endlesss loop. Call GetLastError() ONCE and then use WaitForSingleObject() or GetOverlappedResult() to perform the waiting. Alternatively, get rid of the overlapped I/O altogether. Then WriteFile() will not return until the full data has been written (or an error occurs). Gambit
Technical Details
Message-ID:
<43dfb599$1@newsgroups.borland.com>Path:
arc1-ca.pugleaf.net!g2news1.google.com!news2.google.com!news1.google.com!proxad.net!212.101.4.254.MISMATCH!solnet.ch!solnet.ch!newsfeed.freenet.de!newsfeed00.sul.t-online.de!t-online.de!195.92.193.196.MISMATCH!nntp.theplanet.net!inewsm1.nntp.theplanet.net!news-peer-test!btnet!newsfeed.bt.es!caladan.landsraad.net!newsgroups.borland.com!not-for-mailReferences:
<43dfb314$1@newsgroups.borland.com>Show Full Headers
Complete Article Headers
X-Google-Thread: 10cc67,35d51da2ca244c26 X-Google-Attributes: gid10cc67,public X-Google-Language: ENGLISH,ASCII-7-bit From: "Remy Lebeau \(TeamB\)" <no.spam@no.spam.com> Newsgroups: borland.public.cppbuilder.nativeapi References: <43dfb314$1@newsgroups.borland.com> Subject: Re: Named pipe conundrum Date: Tue, 31 Jan 2006 11:10:36 -0800 Lines: 38 X-Priority: 3 X-MSMail-Priority: Normal X-Newsreader: Microsoft Outlook Express 6.00.2800.1409 X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2800.1409 NNTP-Posting-Host: 68.69.17.41 Message-ID: <43dfb599$1@newsgroups.borland.com> X-Trace: newsgroups.borland.com 1138734489 68.69.17.41 (31 Jan 2006 11:08:09 -0700) Path: arc1-ca.pugleaf.net!g2news1.google.com!news2.google.com!news1.google.com!proxad.net!212.101.4.254.MISMATCH!solnet.ch!solnet.ch!newsfeed.freenet.de!newsfeed00.sul.t-online.de!t-online.de!195.92.193.196.MISMATCH!nntp.theplanet.net!inewsm1.nntp.theplanet.net!news-peer-test!btnet!newsfeed.bt.es!caladan.landsraad.net!newsgroups.borland.com!not-for-mail