connection oriented or message oriented pipe server?
I am currently working on a windows service which is talking to multiple instances of another program. The number of client instances is not fixed and changing dynamically. However the maximum number is relatively low, below 20, and the service can handle the load easily.
The programs are sending messages about every five seconds. These messages are nothing more than simple structs containing two DWORDs, so:
Since every instance is alive over a longer period of time and will send hundreds of messages I wonder if it is better to keep this message oriented approach or switch to a connection oriented approach. I could imagine assigning one instance of the named pipe to one client. So the pipe instance would determine the client's thread id, while the client will not send msg structs, but only the event ids.
In this scenario it will probably have no major impact, but if we assume the clients would send multiple messages per second, I believe a connection oriented approach would be more efficient. The overhead to create a pipe instance is reduced to one time as well as the message traffic is reduced by 50% since only one DWORD needs to be sent.
Both approaches can easily be multithreaded since either a thread is spawned for processing every message, or one thread is spawned for processing and managing one single pipe. If an client is terminated, the piple will be closed.
I wonder if named pipes on Windows are suited for this sort of communication? It appears to me the connection oriented approach is the cleaner, overall more efficient one...