Does anyone have any Delphi example code for a full-duplex peer-to-peer named pipe? I have lots of examples for client/server named pipes, but I need something a bit more sophisticated.

Does anyone have any Delphi example code for a full-duplex peer-to-peer named pipe?  I have lots of examples for client/server named pipes, but I need something a bit more sophisticated.

I am working on a project that uses a Windows Service and a desktop app.  They currently communicate using named pipes, and this works fine.  I am improving the app/service and I want to add full-duplex communications to the project over a single named pipe.  The existing project uses numerous client-server pipes and it is getting too complex with separate one-way pipes for each channel.  My peer efforts are not going well.  My problem is that I can't seem to separate the "transmit and receive" sides of the pipe if I have both talkers and listeners on both ends of the pipe.  When the transmitter sends something to the opposite end of the pipe, the local listener "hears" the transmission and grabs the data:  It never makes it to the other end of the pipe. 

Any ideas?

Comments

  1. Not having studied pipes at all, just a WAG from your description: Maybe it's easier to reduce the numerous pipes not quite all the way to one, but two one-way ones? You'd still get most of the advantages of concentration, having exactly one place to listen and one to talk at each end.

    ReplyDelete
  2. Sounds like a good time to see if ZeroMQ or similar solutions might be easier and better.

    ReplyDelete
  3. Just tested the EDN link. It still compiles on XE7 and works without any changes! :o)

    ReplyDelete
  4. Christian Conrad The pipe count (all currently one-way) is up to about 6.  The simplest solution for this project would be a single duplex pipe - that doesn't swallow its own tail :-)  I have existing infrastructure that can parse the stream coming out of a pipe and send it to the correct parts of the app - so one pipe should suffice.

    ReplyDelete
  5. CHUA Chee Wee  Your code looks very promising!  Thank you very much!  I will try it out tonight.

    ReplyDelete
  6. Ah, well, I thought you had like forty-eleventeen. Then two would have been a good reduction. :-)

    ReplyDelete
  7. Christian Conrad Well, it was 6 going on forty-eleventeen.  That is why I was looking for a more sane and scalable implementation.  :-)

    ReplyDelete
  8. Asbjørn Heid  I looked at ZeroMQ and it seemed overly complex for the relatively simple interface I need.  Their Delphi wrapper dates back to D7, which is a bit scary.  I am on DXE7.

    ReplyDelete

Post a Comment