I was playing around with an app that acts as a named pipe server.
For my applications it would be alot easier if I could connect a
ostream and istream objects to a NamedPipe, so I can send and receive
stuff without doing full calls to WriteFile, ReadFile, ect.
Is their an easy way of doing this?
Thanks
-Arthur Bierer
======================================================================
University of California, San Diego
Arthur Bierer ( Beer )
( email: abi...@ucsd.edu )
Come back here you patsee, tis bit a flesh wound.
I had a similar problem using sockets. I wanted to be able to use the standard fprintf, fscanf, etc.
What I finally did was spawn two threads for each socket connection. The transmit thread did a
blocking read on a anonymous pipe. When the transmit thread read something it simply sent the packet
via normal socket calls. The actual thread creating the data to be sent could use normal stdio
routines since it was writing the other end of the pipe using its file handle. The other thread
acted as a receiver using a blocking read on a socket. Once it recieived something it simply wrote
it to a rcv pipe and looped to do another blocking read. Seems like a lot of hassle just to be able
to use stdio routines but it works okay for me. This method should be adaptable for
C++ streams and named pipes also. Instead of doing blocking reads/writes on sockets use the
Read/WriteFile APIs on the network side. Your application should be able to read/write from anonymous
pipes using normal C++ streams stuff while passing all of the ugly packet xmt/rcv details to the
worker threads which read pipe/WriteFile and ReadFile/write pipe respectively.