问题
I've downloaded and had a play with the Cromis IPC components from Iztok Kacin.
I've downloaded this component set to allow my windows service and GUI to communicate. However it seems that the communication is one way(apart from server responses).
I can quite happily send a message from a client to a listening server, but I don't appear to be able to send a message back to the client unless it is as a response.
Does anyone know if two way comms are achievable with these components or am I going to need a server and a client in both the GUI and service apps?
回答1:
I am the author of the components and as others already told you there is no way to do two way communication at the moment. The reason is simple, its the way named pipes work. It would be very complicated to maintain a permanent connection between client and server and frankly IPC is not about that. But as there are times when you need to be notified that new data is available, I am thinking about rolling independent signaling mechanism. This way server could notify the client that there is something for him. Client would then access the data in the same way as it does now. Right now I am in favor of implementing this as a completely separate component that would then be easily used alongside my IPC.
Follow the blog as I will post about it there if I decide to do this.
回答2:
You will need a server and a client at both sides.
回答3:
Short Answer:
Cromis IPC is a Named Pipe implementation. A client is responsible to send a set of commands, which should be defined as an application specific protocol. Corresponding server listens to clients and acts as a processor to handle these protocol requests. In your case, you want to have a bi-directional communication, so you should create a client and a server on both processes with two protocols.
Long Answer:
You can use Cromis IPC to do the work. As I have described above, you have to define two application specific protocols and write protocol clients and protocol processors yourself. This is a remarkable work.
Recently I ran into Apache Thrift. Apache Thrift aims to provide a high performance IPC framework. One fantastic feature of Apache Thrift is that it can generate the most code for an IPC automatically. And it supports Delphi.
You just have to define application specific protocols in a spec file. Thrift will generate related client and processor code for you. Also it support not only Named Pipe, you can choose sockets or other transport implementations. It is really worth for a try.
来源:https://stackoverflow.com/questions/9740771/two-way-communication-using-cromis-ipc