1. Documentation
This document is a functional description of some functions that are not commonly used in sdk. These functions may be useful for your project in specific scenarios. Before reading this document, please read the sdk description of another general function, which describes the principles of the sdk and how to integrate it more clearly. We have also made sample projects for advanced functions, please check the projects under "demo advanced functions".
2. Resolving port conflicts
After years of observation and statistics, the port conflict problem only occurs in individual client devices and the probability of occurrence and low. However, in order to solve this problem completely, we still recommend you to use our advanced functions to solve this problem completely.
Since our sdk is based on the "forwarding rules" that you configureOpen the appropriate port on the client deviceThis has a very low probability of port conflicts occurring on individual clients.There are two types of port conflicts::
- Scenario 1: A port you configured has been used by another application on an individual client.occupied, then the user will not be able to use your app properly;
- The second scenario: you have multiple applications but use the same instance, and users sometimes open multiple of your applications at the same time on the same device; the first application opened by the user has all the ports of your instance occupied, and the second application opened will not be able to open these ports. This is not a problem on a PC, the second application that opens is working fine, because the second application connects to the sdk through the first application.But it's a problem on mobileThe second app is normal at the beginning, because the second app will connect to the sdk through the first app, the first app will be cut to the background while the user is using the second app, and after a while the first app may be hibernated by the system, and then the second app will not be able to connect. The solution to this problem is very simple.The code process is as follows:::
dunSetAutoChangePort(1);//set to automatically change the conflict port, only need to be called once
int ret = clinkStart(key);//start shield, some systems use start See another document for details, only need to be called once
// Call the following line of code to get a new port when a new connection is needed
int new_tcpPort = dunGetCurrentTCPPort("127.0.10.21", 600);//get the new tcp corresponding port
// next use new_tcpPort to connect to the application
Page 3 sdk Advanced Features Manual
Page 4
//connect("127.0.10.21", new_tcpPort) For example this line of pseudo-code