Multi-process communication between the local with a socket (tcp based protocols)

Local process: ipc server to server, maintains a set of client connections coming in end socket fd, each client sent me the data (pass-through) distributed to all incoming client connections.

Local process: ipc client1 client 1, client server connection, and receive the data distributed by the server to determine whether the data is data (data subscription) you need, if it is to make a deal, otherwise throw away .

Local process: ipc client2 2 for the client, the client connection server 2, and accept the data distribution server, to determine whether the data is data (data subscription) you need, if it is to make a deal, otherwise throw away .

Local process: ipc client3 3 for the client, the client 3 connected to the server, and the server receives data distribution, to determine whether the data is data (data subscription) you need, if it is to make a deal, otherwise throw away .

......

Client 1 and Client 3 requires communication, the client 1 need to subscribe 3 information about the client, the client 3 release data (contains information about the client 1 subscription) to the ipc server, ipc server distributed to all clients, client 1 receives the data, the data is determined and found to be subscribed clients about 3 to make the appropriate processing client terminal 2 is not subscribed, then discarding data.

......

Other client communication process in a similar way, subscription information can be spliced ​​as a data packet header, the client receives the data distribution parses the data and compared with the first subscription information, call the function processing.

Code:

Guess you like

Origin www.cnblogs.com/jest549/p/11443971.html