针对目前终端设备采用固定心跳间隔保活TCP通信长连接的方法中存在资源浪费、网络适应性差等问题,提出一种心跳间隔自适应调节的方法.该方法将二分法应用于查找最优心跳间隔之中,通过不断缩小查找范围确定最优的心跳间隔.在中国移动和中国联通的GPRS网络上对该方法进行测试,结果表明了该方法稳定可靠,可以自适应地找出保活TCP连接的最合适的心跳间隔,使心跳间隔尽可能大,同时能够保证连接的存活.%In order to solve the problems of resource waste and poor network adaptability in the method of using fixed heartbeat interval to keep alive TCP communication in the terminal equipment,a method of adaptive adjustment of heartbeat interval is proposed.In this method,the bisection method is used to find the optimal heartbeat interval.This method was tested under the GPRS network of China Mobile and China Unicom,the experimental results showed that this method was stable and reliable,can be self-adaption to find the most appropriate TCP connection keep alive the heartbeat interval,it can also made heartbeat interval as long as possible,while ensuring the survival of the connection.
展开▼