Let me introduce some of the issues that need attention when designing communication services.
1, the use of short-chain, or long-chain. The advantages of short-chain can be guaranteed to a certain extent the number of concurrent services, each communication is completed, the release of resources, the disadvantage is that each time the need to establish a link, waste of resources, communication time costs increased. Long-chain advantage for the first time need to establish a link, the next direct communication, reduce the short chain every time the establishment of link time; The disadvantage is that no matter whether there is data communication will occupy resources, such as more than 100 resources, perhaps the more than 100 links have no data communication time, also has been accounted for resources.
2, link to have a restart mechanism. Although TCP/IP is a reliable byte-stream protocol, who can guarantee that the link is constant. Who can guarantee that the link is normal?
3, communication module to be independent, support multiple link configuration.
4, communication module to each link between each other, can be designed as multi-threaded, multi-process, asynchronous Select.
5, the communication process can design time-out control, can also be designed to send test messages when the link is idle, for example, with UnionPay communication has test message 0000. The test message can avoid the communication zombie to some extent.