windows - Win32 Named pipe behavior -
win7, x64, c++, win32 api, console app, visual studio community 2015
i've scoured questions on named pipes , can't find answer need.
i'm writing server broadcast data 1 way via named pipe multiple identical clients on same machine. sever , each client in own process (.exe). data sent when all clients have somehow signaled server ready (via named event or other mechanism).
the documentation says multiple clients can connect single pipe instance, proceeds talk multiple instances.
i have few questions pipe on server side:
- for small number of clients , low throughput, simplest: 1 thread, 1 pipe instance; 1 thread , multiple pipe instances; multiple threads , 1 instance per thread?
- if single thread
connectnamedpipe
multiple times on same instance of pipe, mean singlewritefile
broadcast clients have connected particular instance of pipe? - if multiple clients can connect particular instance of pipe, writing pipe server side block until all clients have read previous message?
- is doing one-to-many situation uncommon? why?
the documentation says multiple clients can connect single pipe instance
no, doesn't. misread said.
but proceeds talk multiple instances.
each pipe instance can communicate 1 client @ time. when client finished, server can either disconnect instance , reuse new client, or can destroy instance , create new instance. either way, server must create separate pipe instance each client connects.
1.for small number of clients , low throughput, simplest: 1 thread, 1 pipe instance; 1 thread , multiple pipe instances; multiple threads , 1 instance per thread?
the first way allows 1 client @ time.
the second way allows server create multiple instances handling simultaneous connections, requires overlapped i/o used 1 thread can manage multiple connections.
the third way allows server create multiple instances handling simultaneous connections, simplest server can run each instance in own thread, servicing whichever client connected instance. overlapped i/o not needed.
2.if single thread connectnamedpipe multiple times on same instance of pipe, mean single writefile broadcast clients have connected particular instance of pipe?
3.if multiple clients can connect particular instance of pipe, writing pipe server side block until clients have read previous message?
no , no, because multiple clients cannot connected single instance @ same time.
4.is doing one-to-many situation uncommon?
one-to-many not possible named pipes. can have multiple simultaneous one-to-one connections, , not uncommon broadcast data amongst multiple connections. in case, best of using separate thread each connection, or overlapped i/o. way, if 1 client block, other clients not blocked waiting on it.
Comments
Post a Comment