🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Thread View: comp.os.os2.programmer.misc
2 messages
2 total messages Started by Keith R. Bennett Thu, 14 Oct 1993 18:34
Named Pipes DOS Access Question
#232
Author: Keith R. Bennett
Date: Thu, 14 Oct 1993 18:34
27 lines
1917 bytes
I am creating a named pipe in a full screen OS/2 session.  In a DOS
session, I'm fopen'ing the named pipe and fread'ing from it.

The writing (OS/2) process writes 100 strings to the pipe in a fast
loop.  The reading (DOS) process reads from the pipe, also in a
fast loop.  I have specified the NP_WAIT flag when creating the
pipe.

My problem is this: after reading some strings from the pipe
correctly, the fread() of the DOS process returns 0, indicating that
it failed to read anything from the pipe.

Why is this?  Is the DOS process reading faster than the OS/2
process is writing?  I would like the fread() to be blocking,
and that's why I used NP_WAIT.  Does this parameter work only
in OS/2 sessions?

What is the best way to deal with this situation?  Do I have to loop
until the fread returns something?  Is there any kind of DosSleep()
I can use in a DOS session?

Thanks for any help.
-- 
--------------------------------------------------------------------------
Keith Bennett                            Bennett Business Solutions, Inc.
C++/C Software Development               1605 Ingram Terrace
kbennett@access.digex.net                Silver Spring, MD USA 20906-5932
Re: Named Pipes DOS Access Question
#233
Author: Mikael Wahlgren
Date: Thu, 14 Oct 1993 21:43
34 lines
2235 bytes
kbennett@access.digex.net (Keith R. Bennett) writes:

>The writing (OS/2) process writes 100 strings to the pipe in a fast
>loop.  The reading (DOS) process reads from the pipe, also in a
>fast loop.  I have specified the NP_WAIT flag when creating the
>pipe.

>My problem is this: after reading some strings from the pipe
>correctly, the fread() of the DOS process returns 0, indicating that
>it failed to read anything from the pipe.

>Why is this?  Is the DOS process reading faster than the OS/2
>process is writing?  I would like the fread() to be blocking,
>and that's why I used NP_WAIT.  Does this parameter work only
>in OS/2 sessions?

A pipe have two logical ends (server and client).  When you create the pipe
with the NP_WAIT flag that is only valid for the SERVER end of the pipe.  How
the client end of the pipe is handled is entirely decided by the client
program.

But I don't quite understand what is happening in your case, because all
pipes are OPENed in blocking mode as default and for a DOS program it is
quite hard to change from blocking to non-blocking mode (so perhaps you should
be lucky...:-).

>What is the best way to deal with this situation?  Do I have to loop
>until the fread returns something?  Is there any kind of DosSleep()
>I can use in a DOS session?

Yes there is.  Don't remember it right now though.  Recommend you to look
in the interrupt-list.

Mikael Wahlgren
Thread Navigation

This is a paginated view of messages in the thread with full content displayed inline.

Messages are displayed in chronological order, with the original post highlighted in green.

Use pagination controls to navigate through all messages in large threads.

Back to All Threads