[go: up one dir, main page]

CN105610888A - Method of using socket to push message based on Android and system thereof - Google Patents

Method of using socket to push message based on Android and system thereof Download PDF

Info

Publication number
CN105610888A
CN105610888A CN201510568152.6A CN201510568152A CN105610888A CN 105610888 A CN105610888 A CN 105610888A CN 201510568152 A CN201510568152 A CN 201510568152A CN 105610888 A CN105610888 A CN 105610888A
Authority
CN
China
Prior art keywords
client
socket
server
android
packet
Prior art date
Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
Pending
Application number
CN201510568152.6A
Other languages
Chinese (zh)
Inventor
周国富
肖顺心
李伟
罗智杰
Current Assignee (The listed assignees may be inaccurate. Google has not performed a legal analysis and makes no representation or warranty as to the accuracy of the list.)
South China Normal University
Shenzhen Guohua Optoelectronics Co Ltd
Shenzhen Guohua Optoelectronics Research Institute
Original Assignee
South China Normal University
Shenzhen Guohua Optoelectronics Co Ltd
Shenzhen Guohua Optoelectronics Research Institute
Priority date (The priority date is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the date listed.)
Filing date
Publication date
Application filed by South China Normal University, Shenzhen Guohua Optoelectronics Co Ltd, Shenzhen Guohua Optoelectronics Research Institute filed Critical South China Normal University
Priority to CN201510568152.6A priority Critical patent/CN105610888A/en
Publication of CN105610888A publication Critical patent/CN105610888A/en
Pending legal-status Critical Current

Links

Classifications

    • HELECTRICITY
    • H04ELECTRIC COMMUNICATION TECHNIQUE
    • H04LTRANSMISSION OF DIGITAL INFORMATION, e.g. TELEGRAPHIC COMMUNICATION
    • H04L67/00Network arrangements or protocols for supporting network services or applications
    • H04L67/50Network services
    • H04L67/55Push-based network services
    • HELECTRICITY
    • H04ELECTRIC COMMUNICATION TECHNIQUE
    • H04LTRANSMISSION OF DIGITAL INFORMATION, e.g. TELEGRAPHIC COMMUNICATION
    • H04L63/00Network architectures or network communication protocols for network security
    • H04L63/02Network architectures or network communication protocols for network security for separating internal from external traffic, e.g. firewalls
    • HELECTRICITY
    • H04ELECTRIC COMMUNICATION TECHNIQUE
    • H04LTRANSMISSION OF DIGITAL INFORMATION, e.g. TELEGRAPHIC COMMUNICATION
    • H04L69/00Network arrangements, protocols or services independent of the application payload and not provided for in the other groups of this subclass
    • H04L69/16Implementation or adaptation of Internet protocol [IP], of transmission control protocol [TCP] or of user datagram protocol [UDP]
    • H04L69/161Implementation details of TCP/IP or UDP/IP stack architecture; Specification of modified or new header fields
    • H04L69/162Implementation details of TCP/IP or UDP/IP stack architecture; Specification of modified or new header fields involving adaptations of sockets based mechanisms

Landscapes

  • Engineering & Computer Science (AREA)
  • Computer Networks & Wireless Communication (AREA)
  • Signal Processing (AREA)
  • Computer Security & Cryptography (AREA)
  • Computer Hardware Design (AREA)
  • Computing Systems (AREA)
  • General Engineering & Computer Science (AREA)
  • Mobile Radio Communication Systems (AREA)

Abstract

本发明公开了基于安卓的利用socket推送消息的方法和系统,方法包括:A、服务器端启动并开启socket;B、基于安卓的客户端开启service并在其中启动一线程,在该线程中发起socket连接请求;C、服务器端和客户端建立socket长连接,以用于服务器端和客户端之间进行消息推送;D、客户端按一预频率向服务器端发送心跳包,以进行心跳检测;系统包括服务器模块、客户端模块、连接模块以及探测模块。通过在基于安卓的客户端中开启service并在其中启动一线程,在该线程中建立一个socket连接,并按一预频率向服务器发送心跳检测,保证客户端能随时收到服务器发来的推送信息。

The invention discloses a method and a system for pushing messages based on an android using a socket. The method includes: A. a server starts and opens a socket; B. an android-based client starts a service and starts a thread therein, and initiates a socket in the thread Connection request; C. The server end and the client end establish a socket long connection for message push between the server end and the client end; D. The client end sends a heartbeat packet to the server end at a pre-frequency for heartbeat detection; the system Including server module, client module, connection module and detection module. By starting the service in the Android-based client and starting a thread in it, establishing a socket connection in the thread, and sending heartbeat detection to the server at a pre-frequency, it is ensured that the client can receive push information from the server at any time .

Description

基于安卓的利用socket推送消息的方法和系统Android-based method and system for using socket to push messages

技术领域technical field

本发明涉及移动互联网领域,特别是一种基于安卓的利用socket推送消息的方法和系统。The invention relates to the field of mobile Internet, in particular to an Android-based method and system for pushing messages through sockets.

背景技术Background technique

目前主流的四种基于安卓(Android)系统的消息推送方式分别为:XMPP(ExtensibleMessageingandPresenceProtocol:可扩展消息与存在协议)、GCM服务(GoogleCloudMessaging)、MQTT协议以及使用HTTP轮循方式。其中XMPP协议较复杂、冗余(基于XML)、费流量、费电,部署硬件成本高;GCM是Google推出的云消息服务,即第二代的G2DM,其使用受到安卓版本限制,必须大于2.2版本方可使用,该服务在国内不够稳定、需要用户绑定Google帐号,受限于Google;MQTT是轻量级的、基于代理的“发布/订阅”模式的消息传输协议,目前来说不够成熟、实现较复杂,服务端组件rsmb不开源,部署硬件成本较高;HTTP轮询方式是定时向HTTP服务端接口(WebServiceAPI)获取最新消息,该方式的实时性差。现在使用比较多的推送功能是XMPP,如附图1所示,XMPP中定义了三个角色,客户端,服务器,网关。通信能够在这三者的任意两个之间双向发生。服务器同时承担了客户端信息记录,连接管理和信息的路由功能。网关承担着与异构即时通信系统的互联互通,异构系统可以包括SMS(短信),MSN,ICQ等。基本的网络形式是单客户端通过TCP/IP连接到单服务器,然后在之上传输XML。The current mainstream four message push methods based on the Android system are: XMPP (Extensible Message and Presence Protocol), GCM service (Google Cloud Messaging), MQTT protocol and HTTP round robin. Among them, the XMPP protocol is more complex, redundant (based on XML), traffic and electricity cost, and the cost of deploying hardware is high; GCM is a cloud messaging service launched by Google, that is, the second generation of G2DM. Its use is limited by the Android version and must be greater than 2.2 The service is not stable enough in China and requires users to bind a Google account, which is limited by Google; MQTT is a lightweight, agent-based "publish/subscribe" mode message transmission protocol, which is currently not mature enough , The implementation is more complicated, the server component rsmb is not open source, and the cost of deploying hardware is high; the HTTP polling method is to obtain the latest news from the HTTP server interface (WebServiceAPI) at regular intervals, which has poor real-time performance. Now the push function that is widely used is XMPP, as shown in Figure 1, three roles are defined in XMPP, client, server, and gateway. Communication can occur bi-directionally between any two of the three. The server also undertakes the functions of client information recording, connection management and information routing. The gateway is responsible for interconnection and intercommunication with heterogeneous instant messaging systems, which may include SMS (short message), MSN, ICQ and so on. The basic form of networking is a single client connecting to a single server via TCP/IP, and then transferring XML over it.

Socket方式协议较以上几种协议都更简单,而且稳定,不依赖于特定的公司,很成熟,部署成本不高,实时性最强,尤其是在聊天软件中最能体现。Socket的英文原义是“孔”或“插座”。作为BSDUNIX的进程通信机制,取后一种意思。通常也称作"套接字",用于描述IP地址和端口,是一个通信链的句柄,可以用来实现不同虚拟机或不同计算机之间的通信。在Internet上的主机一般运行了多个服务软件,同时提供几种服务。每种服务都打开一个Socket,并绑定到一个端口上,不同的端口对应于不同的服务。Socket正如其英文原意那样,像一个多孔插座。一台主机犹如布满各种插座的房间,每个插座有一个编号,有的插座提供220伏交流电,有的提供110伏交流电,有的则提供有线电视节目。客户软件将插头插到不同编号的插座,就可以得到不同的服务。The Socket protocol is simpler and more stable than the above protocols. It does not depend on a specific company. It is very mature, the deployment cost is not high, and it has the strongest real-time performance, especially in chat software. The English original meaning of Socket is "hole" or "socket". As the process communication mechanism of BSDUNIX, the latter meaning is taken. Usually also called "socket", it is used to describe IP addresses and ports, and is a handle of a communication chain, which can be used to realize communication between different virtual machines or different computers. Hosts on the Internet generally run multiple service software and provide several services at the same time. Each service opens a Socket and binds to a port, and different ports correspond to different services. Socket is just like its English original meaning, like a porous socket. A host is like a room full of various sockets, each socket has a number, some sockets provide 220-volt alternating current, some provide 110-volt alternating current, and some provide cable TV programs. The client software can get different services by inserting the plugs into sockets with different numbers.

使用socket连接首先要在外部建立一个socket服务器,手机端向服务器发送socket请求,建立一个长连接,这种长连接是稳定,实时的,任何时候有服务器想对客户端推送消息都可以马上收到,理论上socket是会一直保持连接状态的,但是实际应用中socket的长连接会遇到两个问题:第一,由于网络不稳定或服务器负载的原因,socket可能会断开,这样就不能接收推送;第二,由于安卓系统会在内存不够时杀死应用,用户有时也会手动关闭应用,造成socket断开,无法达到我们想要的功能。To use a socket connection, you must first establish a socket server externally. The mobile phone sends a socket request to the server to establish a long connection. This long connection is stable and real-time. Anytime the server wants to push a message to the client, it can be received immediately. , theoretically the socket will remain connected all the time, but the long connection of the socket in the actual application will encounter two problems: first, due to the instability of the network or the load of the server, the socket may be disconnected, so that it cannot receive Push; second, because the Android system will kill the application when the memory is insufficient, the user sometimes manually closes the application, causing the socket to be disconnected, and the function we want cannot be achieved.

发明内容Contents of the invention

本发明的目的在于克服现有技术问题的缺陷,提供一种基于安卓的利用socket推送消息的方法和系统。The purpose of the present invention is to overcome the defects of the prior art problems, and provide a method and system based on Android and using socket to push messages.

根据本发明的一个方面,提供了一种基于安卓的利用socket推送消息的方法,包括如下步骤:According to one aspect of the present invention, there is provided a method for using socket push messages based on Android, comprising the following steps:

A:服务器端启动并开启socket;A: The server starts and opens the socket;

B:基于安卓的客户端开启service并在其中启动一线程,在该线程中发起socket连接请求;B: The Android-based client starts the service and starts a thread in it, and initiates a socket connection request in the thread;

C:服务器端和客户端建立socket长连接,以用于服务器端和客户端之间进行消息推送;C: The server and the client establish a long socket connection for message push between the server and the client;

D:客户端按一预频率向服务器端发送心跳包,以进行心跳检测。D: The client sends a heartbeat packet to the server at a predetermined frequency for heartbeat detection.

优选地,所述service运行在安卓系统后台。Preferably, the service runs in the background of the Android system.

优选地,所述心跳检测包括如下步骤:Preferably, the heartbeat detection includes the steps of:

D1:客户端每隔一个时间间隔发送一个心跳包给服务器端,并同时启动一个超时定时器;D1: The client sends a heartbeat packet to the server at intervals and starts a timeout timer at the same time;

D2:如果客户端收到服务器的应答包,则删除超时定时器;D2: If the client receives the response packet from the server, delete the timeout timer;

D3:如果客户端的超时定时器超时,依然没有收到应答包,则进行重连。D3: If the client's timeout timer expires and the response packet is still not received, reconnect.

优选地,所述时间间隔设置为周期性时间间隔。Preferably, the time interval is set as a periodic time interval.

优选地,所述心跳包设置为小数据包或者只包含包头的空包。Preferably, the heartbeat packet is set as a small data packet or an empty packet containing only a packet header.

优选地,所述应答包设置为小数据包或者只包含包头的空包。Preferably, the response packet is set as a small data packet or an empty packet containing only a packet header.

优选地,所述客户端数量大于1,在每个客户端开启的service数量大于1,每一个service分别与所述服务器端建立socket长连接。Preferably, the number of clients is greater than 1, the number of services opened on each client is greater than 1, and each service establishes a long socket connection with the server.

根据本发明的一个方面,提供了一种基于安卓的利用socket推送消息的系统,包括:According to one aspect of the present invention, a kind of system utilizing socket push message based on Android is provided, comprising:

服务器模块,配置为在服务器端启动并开启socket;The server module is configured to start on the server side and open the socket;

客户端模块,配置为在基于安卓的客户端开启service并在其中启动一线程,在该线程中发起socket连接请求;The client module is configured to start service on the Android-based client and start a thread therein, and initiate a socket connection request in the thread;

连接模块,配置为在服务器端和客户端建立socket长连接,以用于服务器端和客户端之间进行消息推送;The connection module is configured to establish a long socket connection between the server and the client, so as to push messages between the server and the client;

探测模块,配置为在客户端按一预频率向服务器端发送心跳包,以进行心跳检测。The detection module is configured to send a heartbeat packet from the client to the server at a pre-frequency for heartbeat detection.

优选地,所述检测模块包括:Preferably, the detection module includes:

发送单元,配置为在客户端每隔一个时间间隔发送一个心跳包给服务器端;The sending unit is configured to send a heartbeat packet to the server every time interval at the client;

接收单元,配置为在客户端接收服务器的应答包;a receiving unit configured to receive a response packet from the server at the client;

计时单元,配置为在客户端启动一个超时定时器,如果客户端收到服务器的应答包,则删除超时定时器,如果客户端的超时定时器超时,依然没有收到应答包,则进行重连。The timing unit is configured to start a timeout timer on the client. If the client receives a response packet from the server, the timeout timer is deleted. If the client’s timeout timer expires and the response packet is still not received, reconnection is performed.

优选地,所述时间间隔设置为周期性时间间隔。Preferably, the time interval is set as a periodic time interval.

优选地,所述心跳包设置为小数据包或者只包含包头的空包。Preferably, the heartbeat packet is set as a small data packet or an empty packet containing only a packet header.

优选地,所述应答包设置为小数据包或者只包含包头的空包。Preferably, the response packet is set as a small data packet or an empty packet containing only a packet header.

本发明的有益效果是:The beneficial effects of the present invention are:

Service是安卓系统的一个组件,在安卓系统后台运行,当在程序中开启了Service后,即使程序关闭,Service还是能够继续运行,所以在service中建立的socket连接不会因为程序关闭而断开,保证了客户端的socket连接;通过心跳检测可以保证即使由于网络或者防火墙的原因导致的socket断开,也可以及时重连,保证服务器和客户端的连接,使客户端及时接收到来自服务器的推送消息。Service is a component of the Android system that runs in the background of the Android system. When the Service is enabled in the program, the Service can continue to run even if the program is closed, so the socket connection established in the service will not be disconnected because the program is closed. The socket connection of the client is guaranteed; the heartbeat detection can ensure that even if the socket is disconnected due to the network or firewall, it can be reconnected in time to ensure the connection between the server and the client, so that the client can receive the push message from the server in time.

附图说明Description of drawings

下面结合附图和实例对本发明作进一步说明。The present invention will be further described below in conjunction with accompanying drawing and example.

图1是根据现有技术中基于安卓的利用XMPP推送消息的结构示意图。Fig. 1 is a schematic structural diagram of using XMPP to push messages based on Android in the prior art.

图2是根据本发明的基于安卓的利用socket推送消息的结构示意图。Fig. 2 is a schematic structural diagram of using socket to push messages based on Android according to the present invention.

图3是根据本发明第一实施例的基于安卓的利用socket推送消息的方法的流程图;Fig. 3 is the flow chart of the method for utilizing socket push messages based on Android according to the first embodiment of the present invention;

图4是根据本发明第三实施例的基于安卓的利用socket推送消息的系统的模块图。FIG. 4 is a block diagram of an Android-based system for pushing messages through sockets according to a third embodiment of the present invention.

具体实施方式detailed description

本发明提供一种基于安卓的利用socket推送消息的方法和系统,如图2所示,包括服务器端和客户端,服务器端和客户端之间通过socket建立长连接,用于相互之间进行消息推送。The present invention provides a method and a system for pushing messages based on Android using sockets, as shown in Figure 2, including a server and a client, and a long connection is established between the server and the client through a socket for mutual messaging push.

根据本发明的一个实施例,如图3所示,所述socket长连接包括步骤:According to an embodiment of the present invention, as shown in Figure 3, the socket long connection includes steps:

A:服务器端启动并开启socket;A: The server starts and opens the socket;

具体地,服务器端开启一个socket服务端,代码如下:Specifically, the server opens a socket server, the code is as follows:

其中,以//开头的汉字是对代码的解释。Among them, the Chinese characters starting with // are the explanation of the code.

ServerSocketserver=newServerSocket(20000);ServerSocketserver = newServerSocket(20000);

B:基于安卓的客户端开启service并在其中启动一线程,在该线程中发起socket连接请求;B: the Android-based client starts service and starts a thread therein, and initiates a socket connection request in this thread;

具体地,客户端的应用开启时启动service:Specifically, start the service when the client's application is started:

IntentstartIntent=newIntent(Login.this,ClientService.class);IntentstartIntent = newIntent(Login. this, ClientService. class);

startService(startIntent);startService(startIntent);

//服务(service)类//Service (service) class

publicclassClientServiceextendsService{publicclassClientService extendsService{

//重写服务的oncreat方法,新建一个线程//Rewrite the oncreat method of the service and create a new thread

OverrideOverride

publicvoidonCreate(){public voidonCreate(){

//TODOAuto-generatedmethodstub//TODO Auto-generated methods stub

super.onCreate();super.onCreate();

context=getApplicationContext();context = getApplicationContext();

//建立新线程//Create a new thread

ClientConThreadclient=newClientConThread(context);ClientConThreadclient = newClientConThread(context);

client.start();//启动新线程client.start();//Start a new thread

C:服务器端和客户端建立socket长连接,以用于服务器端和客户端之间进行消息推送;C: The server end and the client end establish a socket long connection for pushing messages between the server end and the client end;

线程启动后,就会发起socket连接请求,代码如下:After the thread starts, it will initiate a socket connection request, the code is as follows:

其中,所述service运行在安卓系统后台。Wherein, the service runs in the background of the Android system.

这样就建立了socket连接,由于是在service里建立的,即使程序被系统或用户杀死socket依然还在,这就保证了客户端的socket连接。In this way, the socket connection is established. Since it is established in the service, even if the program is killed by the system or the user, the socket is still there, which ensures the socket connection of the client.

D:客户端按一预频率向服务器端发送心跳包,以进行心跳检测。D: The client sends a heartbeat packet to the server at a predetermined frequency for heartbeat detection.

心跳检测步骤为:The heartbeat detection steps are:

D1:客户端每隔一个时间间隔发送一个心跳包给服务器端,并同时启动一个超时定时器;D1: The client sends a heartbeat packet to the server at intervals and starts a timeout timer at the same time;

D2:如果客户端收到服务器的应答包,则删除超时定时器;D2: If the client receives the response packet from the server, delete the timeout timer;

D3:如果客户端的超时定时器超时,依然没有收到应答包,则进行重连。D3: If the client's timeout timer expires and the response packet is still not received, reconnect.

可以根据需要把时间间隔设置为周期性时间间隔,而对于心跳包和应答包是没有什么特别规定的,可以是很小的数据包,或者只包含包头的一个空包。The time interval can be set as a periodic time interval according to needs, and there is no special regulation for the heartbeat packet and the response packet, which can be a small data packet, or an empty packet containing only the header.

心跳检测代码如下:The heartbeat detection code is as follows:

这样客户端就会定时发送socket请求检测连接,如果发现断开,就进行重连,心跳包的默认发送时间间隔是两个小时,可以根据需要可以设置心跳包的检测时间和次数。In this way, the client will regularly send socket requests to detect the connection, and if it is found to be disconnected, it will reconnect. The default sending interval of the heartbeat packet is two hours, and the detection time and times of the heartbeat packet can be set as needed.

通过这种操作,可以保证即使由于网络,或者防火墙的原因导致的socket断开,也可以及时重连,保证服务器和客户端的连接,使客户端及时收到来自服务器的推送消息。Through this operation, it can be ensured that even if the socket is disconnected due to the network or firewall, it can be reconnected in time to ensure the connection between the server and the client, so that the client can receive the push message from the server in time.

通过以上方法的结合,保证了客户端socket的不断开,和对服务器端连接的保持。使得客户端任何时候都能接收服务器的消息。Through the combination of the above methods, it is ensured that the client socket is not disconnected and the connection to the server is maintained. This enables the client to receive messages from the server at any time.

根据本发明的第二实施例,参照图2,其与第一实施例基本相同,区别在于所述客户端数量大于1,在每个客户端开启的service数量大于1,分别与所述服务器端建立socket长连接。According to the second embodiment of the present invention, with reference to Fig. 2, it is basically the same as the first embodiment, the difference is that the number of clients is greater than 1, and the number of services opened on each client is greater than 1, which are respectively connected to the server Establish a persistent socket connection.

根据本发明的第三实施例,提供了一种基于安卓的利用socket推送消息的系统,包括:According to the third embodiment of the present invention, a kind of Android-based system utilizing socket to push messages is provided, including:

服务器模块,配置为在服务器端启动并开启socket;The server module is configured to start on the server side and open the socket;

客户端模块,配置为在基于安卓的客户端开启service并在其中启动一线程,在该线程中发起socket连接请求;The client module is configured to start service on the Android-based client and start a thread therein, and initiate a socket connection request in the thread;

连接模块,配置为在服务器端和客户端建立socket长连接,以用于服务器端和客户端之间进行消息推送;The connection module is configured to establish a long socket connection between the server and the client, so as to push messages between the server and the client;

探测模块,配置为在客户端按一预频率向服务器端发送心跳包,以进行心跳检测。The detection module is configured to send a heartbeat packet from the client to the server at a pre-frequency for heartbeat detection.

所述检测模块包括:The detection module includes:

发送单元,配置为在客户端每隔一个时间间隔发送一个心跳包给服务器端;The sending unit is configured to send a heartbeat packet to the server every time interval at the client;

接收单元,配置为在客户端接收服务器的应答包;a receiving unit configured to receive a response packet from the server at the client;

计时单元,配置为在客户端启动一个超时定时器,如果客户端收到服务器的应答包,则删除超时定时器,如果客户端的超时定时器超时,依然没有收到应答包,则进行重连。The timing unit is configured to start a timeout timer on the client. If the client receives a response packet from the server, the timeout timer is deleted. If the client’s timeout timer expires and the response packet is still not received, reconnection is performed.

上述各模块的详细实施例与第一实施例相似,这里不做详细描述。The detailed embodiments of the above modules are similar to the first embodiment, and will not be described in detail here.

以上是对本发明的较佳实施进行了具体说明,但本发明创造并不限于所述实施例,熟悉本领域的技术人员在不违背本发明精神的前提下还可作出种种的等同变形或替换,这些等同的变型或替换均包含在本申请权利要求所限定的范围内。The above is a specific description of the preferred implementation of the present invention, but the invention is not limited to the described embodiments, and those skilled in the art can also make various equivalent deformations or replacements without violating the spirit of the present invention. These equivalent modifications or replacements are all within the scope defined by the claims of the present application.

除非一个必需的步骤需要由前面步骤所产生的输入,否则本文描述的步骤的特定顺序仅用于示例性说明,而非限制。Unless a required step requires input generated by a preceding step, the specific order of steps described herein is for illustration only, and not limitation.

Claims (11)

1. the method for utilizing socket PUSH message based on Android, is characterized in that, comprises step:
A: server end starts and opens socket;
B: the client based on Android is opened service and starts therein a thread initiates socket and connects in this threadRequest;
C: server end is set up socket length with client and is connected, and pushes away for carrying out message between server end and clientSend;
D: client sends heartbeat packet by a pre-frequency to server end, to carry out heartbeat detection.
2. the method for utilizing socket PUSH message based on Android according to claim 1, is characterized in that the described heartJump to detect and comprise the steps:
D1: client sends a heartbeat packet to server end every a time interval, and starts an overtime timing simultaneouslyDevice;
D2: if client is received the response packet of server, delete overtime timer;
D3: if the overtime timer of client is overtime, still do not receive response packet, reconnect.
3. the method for utilizing socket PUSH message based on Android according to claim 2, is characterized in that, when describedBetween be set to the periodically time interval.
4. the method for utilizing socket PUSH message based on Android according to claim 2, is characterized in that the described heartJump the sky bag that bag is set to small data packets or only comprises packet header.
5. the method for utilizing socket PUSH message based on Android according to claim 2, is characterized in that, described answeringAnswer the sky bag that bag is set to small data packets or only comprises packet header.
6. the method for utilizing socket PUSH message based on Android according to claim 1, is characterized in that described visitorFamily terminal number amount is greater than 1, and the service quantity of opening in each client is greater than 1, each service respectively with described serviceDevice end is set up the long connection of socket.
7. the system of utilizing socket PUSH message based on Android, is characterized in that, comprising:
Server module, is configured to start and open socket at server end;
Client modules, is configured to open service and start therein a thread in the client based on Android, at this threadMiddle initiation socket connection request;
Link block, is configured to set up socket length in server end and client and is connected, for server end and clientBetween carry out message push;
Detecting module, is configured to send heartbeat packet by a pre-frequency to server end in client, to carry out heartbeat detection.
8. the system of utilizing socket PUSH message based on Android according to claim 7, is characterized in that described inspectionSurvey module comprises:
Transmitting element, is configured to send a heartbeat packet to server end in client every a time interval;
Receiving element, is configured to the response packet at client server;
Timing unit, is configured at overtime timer of client terminal start-up, if client is received the response packet of server,Delete overtime timer, if the overtime timer of client is overtime, still do not receive response packet, reconnect.
9. the system of utilizing socket PUSH message based on Android according to claim 8, is characterized in that, when describedBetween be set to the periodically time interval.
10. the system of utilizing socket PUSH message based on Android according to claim 8, is characterized in that, described inHeartbeat packet is set to small data packets or only comprises the sky bag in packet header.
11. systems of utilizing socket PUSH message based on Android according to claim 8, is characterized in that, described inResponse packet is set to small data packets or only comprises the sky bag in packet header.
CN201510568152.6A 2015-09-08 2015-09-08 Method of using socket to push message based on Android and system thereof Pending CN105610888A (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN201510568152.6A CN105610888A (en) 2015-09-08 2015-09-08 Method of using socket to push message based on Android and system thereof

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN201510568152.6A CN105610888A (en) 2015-09-08 2015-09-08 Method of using socket to push message based on Android and system thereof

Publications (1)

Publication Number Publication Date
CN105610888A true CN105610888A (en) 2016-05-25

Family

ID=55990423

Family Applications (1)

Application Number Title Priority Date Filing Date
CN201510568152.6A Pending CN105610888A (en) 2015-09-08 2015-09-08 Method of using socket to push message based on Android and system thereof

Country Status (1)

Country Link
CN (1) CN105610888A (en)

Cited By (18)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN106210101A (en) * 2016-07-20 2016-12-07 上海携程商务有限公司 Message management system and information management method
CN106254390A (en) * 2016-09-22 2016-12-21 曙光信息产业(北京)有限公司 Information push method and system
CN106407382A (en) * 2016-09-13 2017-02-15 广州爱电牛互联网科技有限公司 System and method for interacting with new energy automobile charging pile based on APP
CN106686056A (en) * 2016-11-25 2017-05-17 济南中维世纪科技有限公司 Android client communication device and method allowing Android client communication device to connect and communicate with server
CN107454184A (en) * 2017-08-22 2017-12-08 深圳先进技术研究院 Android client and server establish the method that stabilizing network is connected
CN107704274A (en) * 2017-08-24 2018-02-16 武汉斗鱼网络科技有限公司 Method, storage medium, equipment and the system waken up for Android application host process
CN108075947A (en) * 2017-07-31 2018-05-25 北京微应软件科技有限公司 The connective maintaining method of storage device, PC ends, communication connection and system
CN108833950A (en) * 2018-06-29 2018-11-16 武汉斗鱼网络科技有限公司 A kind of barrage message issuing method, server, system and storage medium
CN109150956A (en) * 2018-06-25 2019-01-04 百度在线网络技术(北京)有限公司 A kind of implementation method, device, equipment and computer storage medium pushing SDK
CN109921961A (en) * 2019-03-29 2019-06-21 深圳市思迪信息技术股份有限公司 Multistation spot net speed-measuring method and device based on mobile platform
CN109981717A (en) * 2017-12-28 2019-07-05 中国移动通信集团公司 A kind of connection optimization method, device and computer storage medium
CN111737029A (en) * 2020-06-23 2020-10-02 中国建设银行股份有限公司 A server, a data push method, and a data push system
CN111866431A (en) * 2020-07-27 2020-10-30 广州通达汽车电气股份有限公司 Wireless high-speed networking storage system and method for bus monitoring video
CN112700598A (en) * 2020-12-18 2021-04-23 武汉民为技术有限公司 Secret-related file exchange system based on domestic operating system
CN113542408A (en) * 2021-07-14 2021-10-22 首约科技(北京)有限公司 Method for interaction of message between driver and passenger
CN113905005A (en) * 2021-09-30 2022-01-07 完美世界(北京)软件科技发展有限公司 Client state updating method and device for instant messaging
CN115378989A (en) * 2022-08-10 2022-11-22 上海黑眸智能科技有限责任公司 MQTT topic subscription system, method, terminal and medium based on wake-up channel
CN115633081A (en) * 2022-10-13 2023-01-20 南京联创数字科技有限公司 Optimization method based on Eureka heartbeat connection

Citations (6)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN101242427A (en) * 2007-02-09 2008-08-13 华为技术有限公司 A method, system and device for message push
CN103139303A (en) * 2013-02-07 2013-06-05 网易(杭州)网络有限公司 Method, device and system used for maintaining connected heartbeat
US20130151717A1 (en) * 2004-06-30 2013-06-13 Microsoft Corporation Sustaining session connections
CN103401896A (en) * 2013-07-15 2013-11-20 四川公用信息产业有限责任公司 Multi-Android-client service sharing method and system
CN103973718A (en) * 2013-01-25 2014-08-06 成都勤智数码科技股份有限公司 Operation and maintenance message pushing method based on android mobile platform
CN104539581A (en) * 2014-12-01 2015-04-22 百度在线网络技术(北京)有限公司 Information search implementation method and device and network side equipment

Patent Citations (6)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US20130151717A1 (en) * 2004-06-30 2013-06-13 Microsoft Corporation Sustaining session connections
CN101242427A (en) * 2007-02-09 2008-08-13 华为技术有限公司 A method, system and device for message push
CN103973718A (en) * 2013-01-25 2014-08-06 成都勤智数码科技股份有限公司 Operation and maintenance message pushing method based on android mobile platform
CN103139303A (en) * 2013-02-07 2013-06-05 网易(杭州)网络有限公司 Method, device and system used for maintaining connected heartbeat
CN103401896A (en) * 2013-07-15 2013-11-20 四川公用信息产业有限责任公司 Multi-Android-client service sharing method and system
CN104539581A (en) * 2014-12-01 2015-04-22 百度在线网络技术(北京)有限公司 Information search implementation method and device and network side equipment

Cited By (26)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN106210101B (en) * 2016-07-20 2019-06-18 上海携程商务有限公司 Message management system and information management method
CN106210101A (en) * 2016-07-20 2016-12-07 上海携程商务有限公司 Message management system and information management method
CN106407382A (en) * 2016-09-13 2017-02-15 广州爱电牛互联网科技有限公司 System and method for interacting with new energy automobile charging pile based on APP
CN106254390A (en) * 2016-09-22 2016-12-21 曙光信息产业(北京)有限公司 Information push method and system
CN106686056A (en) * 2016-11-25 2017-05-17 济南中维世纪科技有限公司 Android client communication device and method allowing Android client communication device to connect and communicate with server
CN108075947B (en) * 2017-07-31 2024-02-27 北京微应软件科技有限公司 Storage device, PC (personal computer) end and maintenance method and system of communication connection connectivity
CN108075947A (en) * 2017-07-31 2018-05-25 北京微应软件科技有限公司 The connective maintaining method of storage device, PC ends, communication connection and system
CN107454184A (en) * 2017-08-22 2017-12-08 深圳先进技术研究院 Android client and server establish the method that stabilizing network is connected
CN107454184B (en) * 2017-08-22 2020-07-24 深圳先进技术研究院 Method for establishing stable network connection between Android client and server
CN107704274B (en) * 2017-08-24 2019-11-05 武汉斗鱼网络科技有限公司 Method, storage medium, equipment and the system waken up for Android application host process
CN107704274A (en) * 2017-08-24 2018-02-16 武汉斗鱼网络科技有限公司 Method, storage medium, equipment and the system waken up for Android application host process
CN109981717A (en) * 2017-12-28 2019-07-05 中国移动通信集团公司 A kind of connection optimization method, device and computer storage medium
CN109150956A (en) * 2018-06-25 2019-01-04 百度在线网络技术(北京)有限公司 A kind of implementation method, device, equipment and computer storage medium pushing SDK
CN109150956B (en) * 2018-06-25 2021-04-16 百度在线网络技术(北京)有限公司 Method, device and equipment for realizing SDK pushing and computer storage medium
CN108833950B (en) * 2018-06-29 2021-05-28 武汉斗鱼网络科技有限公司 Barrage message issuing method, server, system and storage medium
CN108833950A (en) * 2018-06-29 2018-11-16 武汉斗鱼网络科技有限公司 A kind of barrage message issuing method, server, system and storage medium
CN109921961A (en) * 2019-03-29 2019-06-21 深圳市思迪信息技术股份有限公司 Multistation spot net speed-measuring method and device based on mobile platform
CN111737029A (en) * 2020-06-23 2020-10-02 中国建设银行股份有限公司 A server, a data push method, and a data push system
CN111866431A (en) * 2020-07-27 2020-10-30 广州通达汽车电气股份有限公司 Wireless high-speed networking storage system and method for bus monitoring video
CN112700598A (en) * 2020-12-18 2021-04-23 武汉民为技术有限公司 Secret-related file exchange system based on domestic operating system
CN113542408A (en) * 2021-07-14 2021-10-22 首约科技(北京)有限公司 Method for interaction of message between driver and passenger
CN113542408B (en) * 2021-07-14 2024-04-19 首约科技(北京)有限公司 Method for interaction message between driver and passenger
CN113905005A (en) * 2021-09-30 2022-01-07 完美世界(北京)软件科技发展有限公司 Client state updating method and device for instant messaging
CN115378989A (en) * 2022-08-10 2022-11-22 上海黑眸智能科技有限责任公司 MQTT topic subscription system, method, terminal and medium based on wake-up channel
CN115378989B (en) * 2022-08-10 2023-08-15 深圳华芯信息技术股份有限公司 MQTT theme subscription system, method, terminal and medium based on wake-up channel
CN115633081A (en) * 2022-10-13 2023-01-20 南京联创数字科技有限公司 Optimization method based on Eureka heartbeat connection

Similar Documents

Publication Publication Date Title
CN105610888A (en) Method of using socket to push message based on Android and system thereof
WO2019205907A1 (en) Intelligent device communication platform based on mqtt message protocol
EP2843908B1 (en) Full-duplex bi-directional communication over a remote procedure call based communications protocol, and applications thereof
US7155487B2 (en) Method, system and article of manufacture for data distribution over a network
US9003042B2 (en) P2P file transmission system and method
CN101534302B (en) A method, system and related device for providing TCP service
CN104518973B (en) A method of reliable multicast transmission of data based on SDN environment
WO2013097401A1 (en) Method, gateway and communication system for browser client directly communicating with back-end server
CN112165447B (en) WAF equipment-based network security monitoring method, system and electronic device
CN104486327B (en) Communication method and client side between page and persistent connection server
CN112631788B (en) Data transmission method and data transmission server
US10367893B1 (en) Method and apparatus of performing peer-to-peer communication establishment
CN106941536A (en) Data interactive method between client and server based on http protocol
CN106604119B (en) Network penetration method and system for private cloud equipment of smart television
CN105262836A (en) Information push method of server and push information reception method of client
WO2011015020A1 (en) File transmission method, system and client
CN103401942B (en) Content delivery network node is realized the method and system of web application acceleration
CN103618667A (en) Information transfer method, access gateway and system
US8156209B1 (en) Aggregation devices processing keep-alive messages of point-to-point sessions
CN105743852B (en) Method and system for realizing Socket connection maintaining communication across network gate through http
CN101309187B (en) A data transmission method and system
WO2010148723A1 (en) Telnet method for external terminal and master device, slave device thereof
CN110771117B (en) Session layer communication using ID-oriented network
WO2009011968A1 (en) Endpoint discriminator in network transport protocol startup packets
CN103379130A (en) Network access system and method based on application layer data

Legal Events

Date Code Title Description
C06 Publication
PB01 Publication
C10 Entry into substantive examination
SE01 Entry into force of request for substantive examination
RJ01 Rejection of invention patent application after publication
RJ01 Rejection of invention patent application after publication

Application publication date: 20160525