CN114338461A - A network connection monitoring method and related equipment - Google Patents
A network connection monitoring method and related equipment Download PDFInfo
- Publication number
- CN114338461A CN114338461A CN202111658088.2A CN202111658088A CN114338461A CN 114338461 A CN114338461 A CN 114338461A CN 202111658088 A CN202111658088 A CN 202111658088A CN 114338461 A CN114338461 A CN 114338461A
- Authority
- CN
- China
- Prior art keywords
- network
- internet protocol
- protocol address
- monitoring
- network connection
- 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
Links
- 238000012544 monitoring process Methods 0.000 title claims abstract description 133
- 238000000034 method Methods 0.000 title claims abstract description 39
- 238000012360 testing method Methods 0.000 claims abstract description 66
- 230000005540 biological transmission Effects 0.000 claims abstract description 11
- 230000006870 function Effects 0.000 claims description 29
- 238000004891 communication Methods 0.000 claims description 15
- 238000004590 computer program Methods 0.000 claims description 13
- 230000003993 interaction Effects 0.000 claims description 6
- 238000012806 monitoring device Methods 0.000 claims description 4
- 230000006855 networking Effects 0.000 description 5
- 238000010586 diagram Methods 0.000 description 4
- 238000005538 encapsulation Methods 0.000 description 4
- 238000001514 detection method Methods 0.000 description 3
- 238000011423 initialization method Methods 0.000 description 3
- 230000003287 optical effect Effects 0.000 description 3
- 238000003672 processing method Methods 0.000 description 3
- 239000011800 void material Substances 0.000 description 3
- 239000013307 optical fiber Substances 0.000 description 2
- 230000008569 process Effects 0.000 description 2
- 238000012545 processing Methods 0.000 description 2
- 230000000644 propagated effect Effects 0.000 description 2
- 230000009286 beneficial effect Effects 0.000 description 1
- 239000003795 chemical substances by application Substances 0.000 description 1
- 230000008030 elimination Effects 0.000 description 1
- 238000003379 elimination reaction Methods 0.000 description 1
- 230000007717 exclusion Effects 0.000 description 1
- 239000004065 semiconductor Substances 0.000 description 1
- 238000006467 substitution reaction Methods 0.000 description 1
Images
Landscapes
- Data Exchanges In Wide-Area Networks (AREA)
Abstract
Description
技术领域technical field
本发明实施例涉及数据传输技术领域,尤其涉及一种网络连接监控方法及相关设备。Embodiments of the present invention relate to the technical field of data transmission, and in particular, to a network connection monitoring method and related equipment.
背景技术Background technique
现有技术中在实现网络状态的监控时,常规的方案是对底层的应用编程接口api进行封装,从而对网络状态进行监测,但是对应用编程接口的进行封装的方式只能判断当前用户端是否存在网络连接,而现实生活中往往存在仅是某一应用程序的服务器无法连接,而客户端内其他应用程序仍然可以正常连接的情况,而发生某一应用程序的服务器无法连接时,只能等待应用程序反馈无法连接服务器的信息,只能采用排除法,换另一应用程序进行连接另一服务器的方式排除所述客户端的网络问题,由此,排除法反馈时长,检测效率慢,也不利于用户查找网络连接的断开位置。When monitoring the network status in the prior art, the conventional solution is to encapsulate the underlying application programming interface api to monitor the network status, but the method of encapsulating the application programming interface can only determine whether the current client is There is a network connection, but in real life there is often a situation where only the server of a certain application cannot be connected, while other applications in the client can still be connected normally, and when the server of a certain application cannot be connected, it can only wait. The application program feeds back the information that the server cannot be connected. Only the exclusion method can be used to eliminate the network problem of the client by switching to another application program to connect to another server. Therefore, the elimination method feedback time is long, the detection efficiency is slow, and it is not conducive to The user finds where the network connection is disconnected.
发明内容SUMMARY OF THE INVENTION
本发明实施例提供了一种网络连接监控方法及相关设备,避免了现有技术中无法监测应用程序对应的服务器网络连接状态,只能监测所述客户端整体网络连接状态的问题。The embodiments of the present invention provide a network connection monitoring method and related equipment, which avoid the problem in the prior art that the server network connection state corresponding to the application program cannot be monitored, but the overall network connection state of the client can only be monitored.
第一方面,本发明实施例提供了一种网络连接监控方法,包括:In a first aspect, an embodiment of the present invention provides a network connection monitoring method, including:
基于网络监控组件获取所述客户端当前已连接的网际协议地址,其中,所述网络监控组件为通过构建监控类的方法得到的具有网络监控功能的组件,所述网际协议地址为服务器端与网络的逻辑地址;Obtain the IP address currently connected to the client based on the network monitoring component, wherein the network monitoring component is a component with a network monitoring function obtained by constructing a monitoring class, and the IP address is the server and the network the logical address;
基于所述网际协议地址进行测试操作,获取测试参数,其中,测试操作为检测所述网际协议地址能否进行数据传输的操作;Perform a test operation based on the Internet Protocol address to obtain test parameters, wherein the test operation is an operation of detecting whether the Internet Protocol address can perform data transmission;
基于所述测试参数判断所述网际协议地址的网络连接状态。The network connection state of the Internet Protocol address is determined based on the test parameter.
可选的,在所述基于网络监控组件获取所述客户端当前已连接的网际协议地址的步骤之前,还包括:Optionally, before the step of acquiring the Internet Protocol address that the client is currently connected to, the network-based monitoring component further includes:
调用基础类数据构建网络监控框架;Call the basic class data to build a network monitoring framework;
设置所述网络监控框架参数得到所述网络监控组件。The network monitoring component is obtained by setting the parameters of the network monitoring framework.
可选的,所述基于网络监控组件获取所述客户端当前已连接的网际协议地址的步骤,包括:Optionally, the step of obtaining the IP address currently connected to the client by the network-based monitoring component includes:
根据所述网际协议地址的类型选择对应的目标方式获取所述网际协议地址。The Internet Protocol address is acquired by selecting a corresponding target method according to the type of the Internet Protocol address.
可选的,所述基于所述网际协议地址进行测试操作,获取测试参数的步骤,包括:Optionally, the step of performing a test operation based on the Internet Protocol address and acquiring test parameters includes:
获取用户请求信息,其中,所述用户请求信息包括用于所述客户端与所述服务器的进行数据交互的指针,所述指针为调用所述服务器内数据的数据;obtaining user request information, wherein the user request information includes a pointer for data interaction between the client and the server, and the pointer is data for calling data in the server;
根据所述网际协议地址获取对应所述指针的上下文数据;Acquire context data corresponding to the pointer according to the Internet Protocol address;
可选的,所述基于所述测试参数判断所述网际协议地址的网络连接状态的步骤,包括:Optionally, the step of judging the network connection state of the Internet Protocol address based on the test parameter includes:
基于所述指针的上下文数据获得网络套接字,通过所述网络套接字向所述服务器端发送请求报文来判断所述网际协议地址的网络连接状态。A network socket is obtained based on the context data of the pointer, and a request message is sent to the server through the network socket to determine the network connection state of the Internet Protocol address.
可选的,所述基于所述指针的上下文数据获得网络套接字,通过所述网络套接字向所述服务器端发送请求报文来判断所述网际协议地址的网络连接状态的步骤,还包括:Optionally, the step of obtaining a network socket based on the context data of the pointer, and judging the network connection state of the Internet Protocol address by sending a request message to the server through the network socket, and further: include:
获取所述网络套接字的运行结果,并判断所述网络套接字的运行结果是否为空;Obtain the running result of the network socket, and determine whether the running result of the network socket is empty;
若所述网络套接字的运行结果为空,则确定所述客户端连接的路由器未与所述服务器端数据联通;If the running result of the network socket is empty, it is determined that the router to which the client is connected is not in data communication with the server;
若所述网络套接字的运行结果不为空,则确定所述客户端连接的路由器与所述服务器端进行数据联通。If the running result of the network socket is not empty, it is determined that the router to which the client is connected is in data communication with the server.
可选的,所述方法还包括:Optionally, the method further includes:
当接收到所述网络连接状态后生成监控终止指令;Generate a monitoring termination instruction after receiving the network connection state;
基于所述监控终止指令将所述指针信息设置为空信息,以使所述网络监控组件停止测试。The pointer information is set to null information based on the monitoring termination instruction, so that the network monitoring component stops testing.
可选的,在所述基于网络监控组件获取所述客户端当前已连接的网际协议地址的步骤之前,还包括:Optionally, before the step of acquiring the Internet Protocol address that the client is currently connected to, the network-based monitoring component further includes:
为所述网络监控组件设置数据回调代理,以使所述网络监控组件基于回调代理获取所述网际协议地址。A data callback proxy is set for the network monitoring component, so that the network monitoring component obtains the Internet Protocol address based on the callback proxy.
第二方面,本发明实施例还提供了一种网络连接监控装置,包括:In a second aspect, an embodiment of the present invention further provides a network connection monitoring device, including:
数据获取模块,用于基于网络监控组件获取所述客户端当前已连接的网际协议地址,其中,所述网络监控组件为通过构建监控类的方法得到的具有网络监控功能的组件,所述网际协议地址为服务器端与网络的逻辑地址;A data acquisition module, configured to acquire the currently connected Internet Protocol address of the client based on a network monitoring component, wherein the network monitoring component is a component with a network monitoring function obtained by constructing a monitoring class, and the Internet Protocol The address is the logical address of the server and the network;
测试模块,用于基于所述网际协议地址进行测试操作,获取测试参数,其中,测试操作为检测所述网际协议地址能否进行数据传输的操作;a test module, configured to perform a test operation based on the Internet Protocol address and obtain test parameters, wherein the test operation is an operation of detecting whether the Internet Protocol address can perform data transmission;
判断模块,用于基于所述测试参数判断所述网际协议地址的网络连接状态。A judgment module, configured to judge the network connection state of the Internet Protocol address based on the test parameter.
第三方面,本发明实施例还提供了一种电子设备,所述电子设备包括:存储器、处理器以及存储在所述存储器中并可在所述处理器上运行的计算机程序,其特征在于,所述处理器用于执行存储器中存储的计算机程序时实现如上述的网络连接监控方法的步骤。In a third aspect, an embodiment of the present invention further provides an electronic device, the electronic device includes: a memory, a processor, and a computer program stored in the memory and executable on the processor, characterized in that: The processor is configured to implement the steps of the above-mentioned network connection monitoring method when executing the computer program stored in the memory.
第四方面,本发明实施例还提供了一种计算机可读存储介质,其上存储有计算机程序,所述计算机程序被处理器执行时实现如上述的网络连接监控方法的步骤。In a fourth aspect, an embodiment of the present invention further provides a computer-readable storage medium on which a computer program is stored, and when the computer program is executed by a processor, implements the steps of the above-mentioned network connection monitoring method.
上述发明中的实施例具有如下优点或有益效果:The embodiments in the above invention have the following advantages or beneficial effects:
基于网络监控组件获取所述客户端当前已连接的网际协议地址,其中,所述网络监控组件为通过构建监控类的方法得到的具有网络监控功能的组件,所述网际协议地址为服务器端与网络的逻辑地址;获取与所述客户端内应用程序进行网络连接的网际协议地址,进而为后续判断网际协议地址与所述应用程序是否存在数据联通提供了数据基础;基于所述网际协议地址进行测试操作,获取测试参数,其中,测试操作为检测所述网际协议地址能否进行数据传输的操作;获取用户请求信息,其中,所述用户请求信息包括所述客户端与所述服务器的进行数据交互的指针数据,所述指针数据为对应所述客户端内存地址的请求数据;基于用户请求信息获取所述应用程序的指针数据,为测试所述网际协议地址提供了基础;基于所述测试参数判断所述网际协议地址的网络连接状态,根据所述网际协议地址获取对应所述指针数据的测试参数;基于所述测试参数判断所述网际协议地址是否与所述客户端进行数据联通,以监控网络连接状态。通过所述测试参数判断所述网际协议地址是否与所述客户端进行数据联通,对特定的所述网际协议地址进行判断,避免了现有技术中对底层的应用编程接口api进行封装,对所述客户端整体网络进行监测,细化了监测对象,得到更细化的网络监测结果,可以得到每一个应用程序的联网情况,提高网络监测效率。Obtain the IP address currently connected to the client based on the network monitoring component, wherein the network monitoring component is a component with a network monitoring function obtained by constructing a monitoring class, and the IP address is the server and the network the logical address; obtain the Internet Protocol address for network connection with the application program in the client, and then provide a data basis for the subsequent judgment of whether the Internet Protocol address and the application program have data communication; test based on the Internet Protocol address operation to obtain test parameters, wherein the test operation is an operation to detect whether the Internet Protocol address can perform data transmission; obtain user request information, wherein the user request information includes data interaction between the client and the server The pointer data is the request data corresponding to the memory address of the client; the pointer data of the application is obtained based on the user request information, which provides a basis for testing the Internet Protocol address; judgment based on the test parameters The network connection status of the Internet Protocol address, according to the Internet Protocol address to obtain the test parameters corresponding to the pointer data; based on the test parameters to determine whether the Internet Protocol address and the client are connected to data, so as to monitor the network Connection Status. Judging whether the Internet Protocol address is in data communication with the client through the test parameters, and judging the specific Internet Protocol address, avoids encapsulation of the underlying application programming interface api in the prior art, The overall network of the client is monitored, the monitoring objects are refined, and more detailed network monitoring results can be obtained, the networking situation of each application program can be obtained, and the network monitoring efficiency can be improved.
附图说明Description of drawings
图1是本申请实施例提供的一种网络连接监控方法的流程图;1 is a flowchart of a network connection monitoring method provided by an embodiment of the present application;
图2是本申请实施例提供的一种网络连接监控装置的结构示意图;FIG. 2 is a schematic structural diagram of a network connection monitoring device provided by an embodiment of the present application;
图3是本申请实施例提供的一种电子设备的结构示意图;3 is a schematic structural diagram of an electronic device provided by an embodiment of the present application;
图4是本申请实施例提供的一种存储介质的结构示意图。FIG. 4 is a schematic structural diagram of a storage medium provided by an embodiment of the present application.
具体实施方式Detailed ways
下面结合附图和实施例对本发明作进一步的详细说明。可以理解的是,此处所描述的具体实施例仅仅用于解释本发明,而非对本发明的限定。另外还需要说明的是,为了便于描述,附图中仅示出了与本发明相关的部分而非全部结构。The present invention will be further described in detail below in conjunction with the accompanying drawings and embodiments. It should be understood that the specific embodiments described herein are only used to explain the present invention, but not to limit the present invention. In addition, it should be noted that, for the convenience of description, the drawings only show some but not all structures related to the present invention.
图1为本发明实施例提供的一种网络连接监控方法的流程图,本实施例提供的文本处理方法可适用于监测特定服务器的联网状态的场景。FIG. 1 is a flowchart of a method for monitoring network connection provided by an embodiment of the present invention. The text processing method provided by this embodiment may be applicable to a scenario of monitoring the networking status of a specific server.
如图1所示,该方法具体包括以下步骤:As shown in Figure 1, the method specifically includes the following steps:
S101、基于网络监控组件获取所述客户端当前已连接的网际协议地址,其中,所述网络监控组件为通过构建监控类的方法得到的具有网络监控功能的组件,所述网际协议地址为服务器端与网络的逻辑地址;S101. Obtain the IP address currently connected to the client based on a network monitoring component, wherein the network monitoring component is a component with a network monitoring function obtained by constructing a monitoring class, and the IP address is a server-side with the logical address of the network;
在一种可能的实施方式中,在所述基于网络监控组件获取所述客户端当前已连接的网际协议地址的步骤之前,还包括:In a possible implementation manner, before the step of acquiring the Internet Protocol address to which the client is currently connected by the network-based monitoring component, the method further includes:
调用基础类数据构建网络监控框架;Call the basic class data to build a network monitoring framework;
设置所述网络监控框架参数得到所述网络监控组件。The network monitoring component is obtained by setting the parameters of the network monitoring framework.
示例性的,通过构建函数:Exemplarily, by building the function:
构建一个网络监控框架,所述监控框架的名称为SimplePinger,Instancetype代表返回一个任意值,simplePingerWithHostName代表这个构建所述监控框架的函数,:(NSString*)hostName是构建这个函数的参数,[[SimplePinger alloc]init]是构建一个网络监控框架的功能语句,SimplePinger*pinger是构建好的网络监控框架,pinger.hostName=hostName;为命名语句,将所述网络监控框架命名为客户端名称。Build a network monitoring framework, the name of the monitoring framework is SimplePinger, Instancetype represents returning an arbitrary value, simplePingerWithHostName represents the function for constructing the monitoring framework, :(NSString*)hostName is the parameter for constructing this function, [[SimplePinger alloc ]init] is a function statement for building a network monitoring framework, SimplePinger*pinger is a built network monitoring framework, pinger.hostName=hostName; for a naming statement, the network monitoring framework is named as the client name.
通过设置函数:By setting the function:
设置所述网络监控框架参数得到所述网络监控组件,其中,-(instancetype)init是重写的系统的初始化的方法,if(self=[super init]){是调用的父类的初始化的方法,通过返回参数self,可以通过调用的父类的初始化的方法设置初始值。Set the parameters of the network monitoring framework to obtain the network monitoring component, where -(instancetype)init is the initialization method of the rewritten system, and if(self=[super init]){ is the initialization method of the called parent class , by returning the parameter self, the initial value can be set by calling the initialization method of the parent class.
通过构建一个网络监控框架,使得所述网络监控组件的过程方便快捷,所述网络监控组件使得检测特定服务器得以实现,也为后续检测提供了工具,进而获取与所述客户端内应用程序进行网络连接的网际协议地址,进而为后续判断网际协议地址与所述应用程序是否存在数据联通提供了数据基础。By constructing a network monitoring framework, the process of the network monitoring component is convenient and fast, the network monitoring component enables the detection of a specific server, and also provides a tool for subsequent detection, and further obtains the network connection with the application in the client. The Internet Protocol address of the connection, thereby providing a data basis for the subsequent determination of whether there is data communication between the Internet Protocol address and the application program.
在一种可能的实施方式中,所述基于网络监控组件获取所述客户端当前已连接的网际协议地址的步骤,包括:In a possible implementation manner, the step of obtaining, by the network-based monitoring component, the IP address that the client is currently connected to includes:
根据所述网际协议地址的类型选择对应的目标方式获取所述网际协议地址。The Internet Protocol address is acquired by selecting a corresponding target method according to the type of the Internet Protocol address.
示例性的,通过选择函数:Exemplarily, by selecting the function:
-(void)startForceIPv4:(BOOL)forceIPv4 forceIPv6:(BOOL)forceIPv6{-(void)startForceIPv4:(BOOL)forceIPv4 forceIPv6:(BOOL)forceIPv6{
选择对应的目标方式获取所述网际协议地址,其中,startForceIPv4是强制监听的函数,(BOOL)forceIPv4是强制监听的ipv4的地址,forceIPv6是强制监听的ipv6的地址,所述选择函数的函数逻辑为:Select the corresponding target mode to obtain the Internet Protocol address, wherein, startForceIPv4 is the function of forced monitoring, (BOOL) forceIPv4 is the address of forced monitoring ipv4, forceIPv6 is the address of forced monitoring ipv6, and the function logic of the selection function is :
判定是否存在ipv4类型的网际协议地址,不存在ipv6类型的网际协议地址,Determine whether there is an Internet Protocol address of ipv4 type, and there is no Internet Protocol address of ipv6 type,
若是,则将ipv4的地址赋值给所述网络监控组件的对象;If so, assign the address of ipv4 to the object of the network monitoring component;
若ipv6类型的网际协议地址存在,ipv4类型的网际协议地址不存在,则将ipv6的地址赋值给这个所述网络监控组件的对象。If the internet protocol address of ipv6 type exists and the internet protocol address of ipv4 type does not exist, the ipv6 address is assigned to the object of the network monitoring component.
避免了由于所述网际协议地址的类型不同,采用错误的获取方法,无法获取所述网际协议地址,进而导致监控过程崩溃,或者误导用户做出错误判断。通过根据所述网际协议地址的类型选择对应的目标方式获取所述网际协议地址,保证所述网络监控组件运行正常,所述网络监控组件获取的所述网际协议地址为正确数据。It is avoided that the Internet protocol address cannot be obtained by adopting a wrong acquisition method due to the different types of the Internet protocol address, thereby causing the monitoring process to crash, or misleading the user to make a wrong judgment. Obtaining the Internet Protocol address by selecting a corresponding target method according to the type of the Internet Protocol address ensures that the network monitoring component operates normally, and the Internet Protocol address obtained by the network monitoring component is correct data.
在一种可能的实施方式中,在所述基于网络监控组件获取所述客户端当前已连接的网际协议地址的步骤之前,还包括:In a possible implementation manner, before the step of acquiring the Internet Protocol address to which the client is currently connected by the network-based monitoring component, the method further includes:
为所述网络监控组件设置数据回调代理,以使所述网络监控组件基于回调代理获取所述网际协议地址。A data callback proxy is set for the network monitoring component, so that the network monitoring component obtains the Internet Protocol address based on the callback proxy.
示例性的,通过功能语句:Exemplarily, via a function statement:
self.pinger.delegate=selfself.pinger.delegate=self
为所述网络监控组件设置数据回调代理,以使所述网络监控组件基于回调代理获取所述网际协议地址。A data callback proxy is set for the network monitoring component, so that the network monitoring component obtains the Internet Protocol address based on the callback proxy.
设置了所述网络监控组件回调代理,使得所述网际协议地址可以通过回调被所述网络监控组件接收,保证了所述网络监控组件的工作流畅性。The network monitoring component callback agent is set, so that the Internet protocol address can be received by the network monitoring component through callback, which ensures the smooth working of the network monitoring component.
S102、基于所述网际协议地址进行测试操作,获取测试参数,其中,测试操作为检测所述网际协议地址能否进行数据传输的操作;S102, performing a test operation based on the Internet Protocol address to obtain test parameters, wherein the test operation is an operation of detecting whether the Internet Protocol address can perform data transmission;
在一种可能的实施方式中,所述基于所述网际协议地址进行测试操作,获取测试参数的步骤,包括:In a possible implementation manner, the step of performing a test operation based on the Internet Protocol address and acquiring test parameters includes:
获取用户请求信息,其中,所述用户请求信息包括用于所述客户端与所述服务器的进行数据交互的指针,所述指针为调用所述服务器内数据的数据;obtaining user request information, wherein the user request information includes a pointer for data interaction between the client and the server, and the pointer is data for calling data in the server;
根据所述网际协议地址获取对应所述指针的上下文数据;Acquire context data corresponding to the pointer according to the Internet Protocol address;
S103、基于所述测试参数判断所述网际协议地址的网络连接状态。S103. Determine the network connection state of the Internet Protocol address based on the test parameter.
在具体实现中,本实施例基于所述指针的上下文数据获得网络套接字,通过所述网络套接字向所述服务器端发送请求报文来判断所述网际协议地址的网络连接状态;In a specific implementation, this embodiment obtains a network socket based on the context data of the pointer, and sends a request message to the server through the network socket to determine the network connection state of the Internet Protocol address;
可理解的是,通过底层网络套接字socket就可以实现去连接指定的服务器端,例如向指定的服务器发送因特网报文控制协议请求报文,进而可以判断所指的服务器的联网状态。It is understandable that the connection to the specified server can be realized through the underlying network socket, for example, sending an Internet Message Control Protocol request message to the specified server, and then the networking status of the specified server can be judged.
示例性的,通过测试函数:Exemplary, passing the test function:
获取对应所述指针的上下文数据,_bridge void*是指针,CFSocketContextcontext=为获取对应所述指针的上下文数据,CFRunLoopSourceRef是获取当前的函数的loop源地址,这个源地址的变量是rls,strongDelegate是一个id的内容变量,所述id需要遵守SimplePingDelegate协议;Obtain the context data corresponding to the pointer, _bridge void* is the pointer, CFSocketContextcontext= is to obtain the context data corresponding to the pointer, CFRunLoopSourceRef is the loop source address of the current function, the variable of this source address is rls, and strongDelegate is an id The content variable, the id needs to comply with the SimplePingDelegate protocol;
通过所述指针的上下文数据反映所述指针的运行状态与运行结果,基于所述运行状态推到出对应所述指针的所述网际协议地址是否允许数据传输,进而实现针对特定的所述网际协议地址进行判断。The running state and running result of the pointer are reflected through the context data of the pointer, and based on the running state, it is deduced whether the Internet protocol address corresponding to the pointer allows data transmission, thereby realizing the specific Internet protocol address to judge.
示例性的,通过生成函数:Exemplarily, by generating the function:
基于所述运行参数生成运行结果,其中,CFAutorelease是可以对所述socket进行释放的操作,CFSocketCreateWithNative是创建一个native的socket的功能语句,kCFSocketReadCallBack代表是一个回调操作的功能语句,SocketReadCallback是读取回调的操作,context是所述对应指针的上下文数据,socket为网络套接字的运行结果。Generate a running result based on the running parameters, wherein CFAutorelease is an operation that can release the socket, CFSocketCreateWithNative is a function statement to create a native socket, kCFSocketReadCallBack represents a function statement of a callback operation, and SocketReadCallback is a read callback Operation, context is the context data of the corresponding pointer, and socket is the running result of the network socket.
通过所述测试参数判断所述网际协议地址是否与所述客户端进行数据联通,对特定的所述网际协议地址进行判断,避免了现有技术中对底层的应用编程接口api进行封装,对所述客户端整体网络进行监测,细化了监测对象,得到更细化的网络监测结果,可以得到每一个应用程序的联网情况,提高用户体验。Judging whether the Internet Protocol address is in data communication with the client through the test parameters, and judging the specific Internet Protocol address, avoids encapsulation of the underlying application programming interface api in the prior art, The overall network of the client is monitored, the monitoring objects are refined, and more detailed network monitoring results are obtained, the networking situation of each application program can be obtained, and the user experience can be improved.
进一步地,在上述方案基础上,所述基于所述指针的上下文数据获得网络套接字,通过所述网络套接字向所述服务器端发送请求报文来判断所述网际协议地址的网络连接状态的步骤,还包括:Further, on the basis of the above solution, the network socket is obtained based on the context data of the pointer, and the network connection of the Internet Protocol address is determined by sending a request message to the server through the network socket. Status steps also include:
获取所述网络套接字的运行结果,并判断所述网络套接字的运行结果是否为空;Obtain the running result of the network socket, and determine whether the running result of the network socket is empty;
若所述网络套接字的运行结果为空,则确定所述客户端连接的路由器未与所述服务器端数据联通;If the running result of the network socket is empty, it is determined that the router to which the client is connected is not in data communication with the server;
若所述网络套接字的运行结果不为空,则确定所述客户端连接的路由器与所述服务器端进行数据联通。If the running result of the network socket is not empty, it is determined that the router to which the client is connected is in data communication with the server.
可理解的是,基于socket的运行结果可以判断路由器的工作状态,如果路由器联网的网络套接字socket是有值的(不为空),则表明路由器联网;如果路由器联网的网络套接字socket是没有值的(为空),则表明路由器未进行联网;It is understandable that the working state of the router can be judged based on the running result of the socket. If the network socket socket of the router is connected to the Internet with a value (not empty), it indicates that the router is connected to the network; if the network socket of the router is connected to the network If it has no value (empty), it means that the router is not connected to the Internet;
通过网络套接字socket的运行结果对路由器的工作状态进行判断,从而能够判断网络故障的具体位置,有利于查找网络断开的原因,避免无效工作。The working state of the router is judged through the running result of the network socket, so that the specific location of the network failure can be judged, which is helpful for finding the cause of the network disconnection and avoiding invalid work.
在一种可能的实施方式中,所述方法还包括:In a possible implementation, the method further includes:
当接收到所述网络连接状态后生成监控终止指令;Generate a monitoring termination instruction after receiving the network connection state;
基于所述监控终止指令将所述指针信息设置为空信息,以使所述网络监控组件停止测试。The pointer information is set to null information based on the monitoring termination instruction, so that the network monitoring component stops testing.
示例性的,通过停止函数:Exemplarily, by stopping the function:
当接收到所述网络连接状态后,将所述指针信息设置为空信息,以使所述网络监控组件停止测试,其中,-(void)代表这个结束监控的函数是一个没有返回值的函数,stopHostResolution代表结束这个监控的函数,self.host!=NULL是一个比较语句,代表当前的host是否不等于null,若不等于,则执行后续的操作;若当前的host等于null,则停止后续操作,CFHostSetClient是host的客户端的值,self.host是当前的host地址,null是代表将这个host设置为null,即,将所述指针信息设置为空信息,CFHostUnscheduleFromRunLoop代表结束当前的runloop循环的功能语句,CFRunLoopGetCurrent是代表获取当前的host值,kCFRunLoopDefaultMode是获取到当前的host的模型,最终将self.host设置为null。After receiving the network connection status, the pointer information is set to empty information, so that the network monitoring component stops testing, wherein -(void) represents that the function for ending monitoring is a function without a return value, stopHostResolution represents the function to end this monitoring, self.host! =NULL is a comparison statement, which means whether the current host is not equal to null, if not, execute subsequent operations; if the current host is equal to null, stop subsequent operations, CFHostSetClient is the value of the client of the host, and self.host is The current host address, null means that the host is set to null, that is, the pointer information is set to empty information, CFHostUnscheduleFromRunLoop means the function statement to end the current runloop loop, CFRunLoopGetCurrent means to get the current host value, kCFRunLoopDefaultMode means to get to the current host's model, eventually setting self.host to null.
通过释放host,对应host的网络套接字socket也会被释放,进而完成了资源监控的释放,对一些变量进行释放,避免多个监控之间互相影响,数据错乱,同时可以节约内存。By releasing the host, the network socket socket corresponding to the host will also be released, thus completing the release of resource monitoring, and releasing some variables to avoid mutual influence between multiple monitors, data confusion, and memory savings.
基于网络监控组件获取所述客户端当前已连接的网际协议地址,其中,所述网络监控组件为通过构建监控类的方法得到的具有网络监控功能的组件,所述网际协议地址为服务器端与网络的逻辑地址;获取与所述客户端内应用程序进行网络连接的网际协议地址,进而为后续判断网际协议地址与所述应用程序是否存在数据联通提供了数据基础;获取用户请求信息,其中,所述用户请求信息包括所述客户端与所述服务器的进行数据交互的指针数据,所述指针数据为对应所述客户端内存地址的请求数据;基于用户请求信息获取所述应用程序的指针数据,为测试所述网际协议地址提供了基础;根据所述网际协议地址获取对应所述指针数据的测试参数,其中,所述测试参数包括与所述指针数据相关的所有关联进程;基于所述测试参数判断所述网际协议地址是否与所述客户端进行数据联通,以监控网络连接状态。通过所述测试参数判断所述网际协议地址是否与所述客户端进行数据联通,对特定的所述网际协议地址进行判断,避免了现有技术中对底层的应用编程接口api进行封装,对所述客户端整体网络进行监测,细化了监测对象,得到更细化的网络监测结果,进而可以实现对指定的服务器的监控,可以得到每一个应用程序的联网情况,甚至通过获取网络套接字可以对路由器的工作状态进行判断,进而能够判断路由器本身是否联网,提高用户体验。Obtain the currently connected Internet Protocol address of the client based on a network monitoring component, wherein the network monitoring component is a component with a network monitoring function obtained by constructing a monitoring class, and the Internet Protocol address is the server and the network the logical address; obtain the Internet Protocol address for network connection with the application program in the client, and then provide a data basis for the subsequent judgment of whether the Internet Protocol address and the application program have data communication; obtain user request information, wherein, all The user request information includes pointer data for data interaction between the client and the server, and the pointer data is request data corresponding to the memory address of the client; the pointer data of the application is obtained based on the user request information, Provides a basis for testing the internet protocol address; obtains test parameters corresponding to the pointer data according to the internet protocol address, wherein the test parameters include all associated processes related to the pointer data; based on the test parameters It is judged whether the Internet Protocol address is in data communication with the client, so as to monitor the network connection state. Judging whether the Internet Protocol address is in data communication with the client through the test parameters, and judging the specific Internet Protocol address, avoids encapsulation of the underlying application programming interface api in the prior art, The overall network of the client can be monitored, the monitoring objects are refined, and more detailed network monitoring results can be obtained, and then the monitoring of the specified server can be realized. The working state of the router can be judged, and then it can be judged whether the router itself is connected to the Internet, and the user experience can be improved.
以下是本发明实施例提供的文本处理装置的实施例,该装置与上述各实施例的文本处理方法属于同一个发明构思,在文本处理装置的实施例中未详尽描述的细节内容,可以参考上述文本处理方法的实施例。The following is an embodiment of the text processing apparatus provided by the embodiments of the present invention, which belongs to the same inventive concept as the text processing methods of the above-mentioned embodiments. For details that are not described in detail in the embodiments of the text processing apparatus, please refer to the above Embodiments of text processing methods.
图2为本发明实施例二提供的一种网络连接监控装置的结构示意图,该装置具体包括:2 is a schematic structural diagram of a network connection monitoring device provided in Embodiment 2 of the present invention, and the device specifically includes:
数据获取模块201,用于基于网络监控组件获取所述客户端当前已连接的网际协议地址,其中,所述网络监控组件为通过构建监控类的方法得到的具有网络监控功能的组件,所述网际协议地址为服务器端与网络的逻辑地址;A
测试模块202,用于基于所述网际协议地址进行测试操作,获取测试参数,其中,测试操作为检测所述网际协议地址能否进行数据传输的操作;A
判断模块203,用于基于所述测试参数判断所述网际协议地址的网络连接状态。The
基于网络监控组件获取所述客户端当前已连接的网际协议地址,其中,所述网络监控组件为通过构建监控类的方法得到的具有网络监控功能的组件,所述网际协议地址为服务器端与网络的逻辑地址;获取与所述客户端内应用程序进行网络连接的网际协议地址,进而为后续判断网际协议地址与所述应用程序是否存在数据联通提供了数据基础;基于所述网际协议地址进行测试操作,获取测试参数,其中,测试操作为检测所述网际协议地址能否进行数据传输的操作;获取用户请求信息,其中,所述用户请求信息包括所述客户端与所述服务器的进行数据交互的指针数据,所述指针数据为对应所述客户端内存地址的请求数据;基于用户请求信息获取所述应用程序的指针数据,为测试所述网际协议地址提供了基础;基于所述测试参数判断所述网际协议地址的网络连接状态,根据所述网际协议地址获取对应所述指针数据的测试参数;基于所述测试参数判断所述网际协议地址是否与所述客户端进行数据联通,以监控网络连接状态。通过所述测试参数判断所述网际协议地址是否与所述客户端进行数据联通,对特定的所述网际协议地址进行判断,避免了现有技术中对底层的应用编程接口api进行封装,对所述客户端整体网络进行监测,细化了监测对象,得到更细化的网络监测结果,可以得到每一个应用程序的联网情况,提高用户体验。Obtain the IP address currently connected to the client based on the network monitoring component, wherein the network monitoring component is a component with a network monitoring function obtained by constructing a monitoring class, and the IP address is the server and the network the logical address; obtain the Internet Protocol address for network connection with the application program in the client, and then provide a data basis for the subsequent judgment of whether the Internet Protocol address and the application program have data communication; test based on the Internet Protocol address operation to obtain test parameters, wherein the test operation is an operation to detect whether the Internet Protocol address can perform data transmission; obtain user request information, wherein the user request information includes data interaction between the client and the server The pointer data is the request data corresponding to the memory address of the client; the pointer data of the application is obtained based on the user request information, which provides a basis for testing the Internet Protocol address; judgment based on the test parameters The network connection status of the Internet Protocol address, according to the Internet Protocol address to obtain the test parameters corresponding to the pointer data; based on the test parameters to determine whether the Internet Protocol address and the client are connected to data, so as to monitor the network Connection Status. Judging whether the Internet Protocol address is in data communication with the client through the test parameters, and judging the specific Internet Protocol address, avoids encapsulation of the underlying application programming interface api in the prior art, The overall network of the client is monitored, the monitoring objects are refined, and more detailed network monitoring results are obtained, the networking situation of each application program can be obtained, and the user experience can be improved.
在一种可能的实施方式中,如图3所示,本申请实施例提供了一种电子设备,包括存储器310、处理器320及存储在存储器310上并可在处理器320上运行的计算机程序311,处理器320执行计算机程序311时实现上述网络连接监控方法的步骤。In a possible implementation manner, as shown in FIG. 3 , an embodiment of the present application provides an electronic device including a
在一种可能的实施方式中,如图4所示,本实施例提供了一种计算机可读存储介质400,其上存储有计算机程序411,该计算机程序411被处理器执行时实现上述网络连接监控方法的步骤。In a possible implementation manner, as shown in FIG. 4 , this embodiment provides a computer-
本发明实施例的计算机存储介质,可以采用一个或多个计算机可读的介质的任意组合。计算机可读介质可以是计算机可读信号介质或者计算机可读存储介质。计算机可读存储介质例如可以是但不限于:电、磁、光、电磁、红外线、或半导体的系统、装置或器件,或者任意以上的组合。计算机可读存储介质的更具体的例子(非穷举的列表)包括:具有一个或多个导线的电连接、便携式计算机磁盘、硬盘、随机存取存储器(RAM)、只读存储器(ROM)、可擦式可编程只读存储器(EPROM或闪存)、光纤、便携式紧凑磁盘只读存储器(CD-ROM)、光存储器件、磁存储器件、或者上述的任意合适的组合。在本文件中,计算机可读存储介质可以是任何包含或存储程序的有形介质,该程序可以被指令执行系统、装置或者器件使用或者与其结合使用。The computer storage medium in the embodiments of the present invention may adopt any combination of one or more computer-readable mediums. The computer-readable medium may be a computer-readable signal medium or a computer-readable storage medium. The computer-readable storage medium may be, for example, but not limited to, an electrical, magnetic, optical, electromagnetic, infrared, or semiconductor system, apparatus or device, or any combination of the above. More specific examples (a non-exhaustive list) of computer readable storage media include: electrical connections having one or more wires, portable computer disks, hard disks, random access memory (RAM), read only memory (ROM), Erasable programmable read only memory (EPROM or flash memory), optical fiber, portable compact disk read only memory (CD-ROM), optical storage devices, magnetic storage devices, or any suitable combination of the foregoing. In this document, a computer-readable storage medium can be any tangible medium that contains or stores a program that can be used by or in conjunction with an instruction execution system, apparatus, or device.
计算机可读的信号介质可以包括在基带中或者作为载波一部分传播的数据信号,其中承载了计算机可读的程序代码。这种传播的数据信号可以采用多种形式,包括但不限于电磁信号、光信号或上述的任意合适的组合。计算机可读的信号介质还可以是计算机可读存储介质以外的任何计算机可读介质,该计算机可读介质可以发送、传播或者传输用于由指令执行系统、装置或者器件使用或者与其结合使用的程序。A computer-readable signal medium may include a propagated data signal in baseband or as part of a carrier wave, with computer-readable program code embodied thereon. Such propagated data signals may take a variety of forms, including but not limited to electromagnetic signals, optical signals, or any suitable combination of the foregoing. A computer-readable signal medium can also be any computer-readable medium other than a computer-readable storage medium that can transmit, propagate, or transport the program for use by or in connection with the instruction execution system, apparatus, or device .
计算机可读介质上包含的程序代码可以用任何适当的介质传输,包括但不限于:无线、电线、光缆、RF等等,或者上述的任意合适的组合。Program code embodied on a computer readable medium may be transmitted using any suitable medium including, but not limited to, wireless, wireline, optical fiber cable, RF, etc., or any suitable combination of the foregoing.
可以以一种或多种程序设计语言或其组合来编写用于执行本发明操作的计算机程序代码,所述程序设计语言包括面向对象的程序设计语言,诸如Java、Smalltalk、C++,还包括常规的过程式程序设计语言—诸如“C”语言或类似的程序设计语言。程序代码可以完全地在用户计算机上执行、部分地在用户计算机上执行、作为一个独立的软件包执行、部分在用户计算机上部分在远程计算机上执行、或者完全在远程计算机或服务器上执行。在涉及远程计算机的情形中,远程计算机可以通过任意种类的网络,包括局域网(LAN)或广域网(WAN),连接到用户计算机,或者,可以连接到外部计算机(例如利用因特网服务提供商来通过因特网连接)。Computer program code for carrying out operations of the present invention may be written in one or more programming languages, including object-oriented programming languages, such as Java, Smalltalk, C++, and conventional Procedural programming language - such as the "C" language or similar programming language. The program code may execute entirely on the user's computer, partly on the user's computer, as a stand-alone software package, partly on the user's computer and partly on a remote computer, or entirely on the remote computer or server. In the case of a remote computer, the remote computer may be connected to the user's computer through any kind of network, including a local area network (LAN) or wide area network (WAN), or may be connected to an external computer (eg, through the Internet using an Internet service provider) connect).
本领域普通技术人员应该明白,上述的本发明的各模块或各步骤可以用通用的计算装置来实现,它们可以集中在单个计算装置上,或者分布在多个计算装置所组成的网络上,可选地,他们可以用计算机装置可执行的程序代码来实现,从而可以将它们存储在存储装置中由计算装置来执行,或者将它们分别制作成各个集成电路模块,或者将它们中的多个模块或步骤制作成单个集成电路模块来实现。这样,本发明不限制于任何特定的硬件和软件的结合。Those of ordinary skill in the art should understand that the above-mentioned modules or steps of the present invention can be implemented by a general-purpose computing device, and they can be centralized on a single computing device, or distributed on a network composed of multiple computing devices. Optionally, they may be implemented in program code executable by a computer device, so that they can be stored in a storage device and executed by the computing device, or they can be fabricated separately into individual integrated circuit modules, or a plurality of modules of them Or the steps are made into a single integrated circuit module to realize. As such, the present invention is not limited to any specific combination of hardware and software.
注意,上述仅为本发明的较佳实施例及所运用技术原理。本领域技术人员会理解,本发明不限于这里所述的特定实施例,对本领域技术人员来说能够进行各种明显的变化、重新调整和替代而不会脱离本发明的保护范围。因此,虽然通过以上实施例对本发明进行了较为详细的说明,但是本发明不仅仅限于以上实施例,在不脱离本发明构思的情况下,还可以包括更多其他等效实施例,而本发明的范围由所附的权利要求范围决定。Note that the above are only preferred embodiments of the present invention and applied technical principles. Those skilled in the art will understand that the present invention is not limited to the specific embodiments described herein, and various obvious changes, readjustments and substitutions can be made by those skilled in the art without departing from the protection scope of the present invention. Therefore, although the present invention has been described in detail through the above embodiments, the present invention is not limited to the above embodiments, and can also include more other equivalent embodiments without departing from the concept of the present invention. The scope is determined by the scope of the appended claims.
Claims (10)
Priority Applications (1)
| Application Number | Priority Date | Filing Date | Title |
|---|---|---|---|
| CN202111658088.2A CN114338461A (en) | 2021-12-30 | 2021-12-30 | A network connection monitoring method and related equipment |
Applications Claiming Priority (1)
| Application Number | Priority Date | Filing Date | Title |
|---|---|---|---|
| CN202111658088.2A CN114338461A (en) | 2021-12-30 | 2021-12-30 | A network connection monitoring method and related equipment |
Publications (1)
| Publication Number | Publication Date |
|---|---|
| CN114338461A true CN114338461A (en) | 2022-04-12 |
Family
ID=81019457
Family Applications (1)
| Application Number | Title | Priority Date | Filing Date |
|---|---|---|---|
| CN202111658088.2A Pending CN114338461A (en) | 2021-12-30 | 2021-12-30 | A network connection monitoring method and related equipment |
Country Status (1)
| Country | Link |
|---|---|
| CN (1) | CN114338461A (en) |
Cited By (1)
| Publication number | Priority date | Publication date | Assignee | Title |
|---|---|---|---|---|
| WO2023221947A1 (en) * | 2022-05-20 | 2023-11-23 | 阿里巴巴(中国)有限公司 | Data transmission method for cloud application, and computing device and computer storage medium |
Citations (5)
| Publication number | Priority date | Publication date | Assignee | Title |
|---|---|---|---|---|
| US6397255B1 (en) * | 1998-12-23 | 2002-05-28 | At&T Corp. | Method and apparatus for providing intelligent network services |
| CN107332739A (en) * | 2017-07-28 | 2017-11-07 | 广东欧珀移动通信有限公司 | Network detection method, network detection device and intelligent terminal |
| CN107360059A (en) * | 2017-07-28 | 2017-11-17 | 广东欧珀移动通信有限公司 | Network detecting method, network detection means and intelligent terminal |
| CN113472607A (en) * | 2021-06-29 | 2021-10-01 | 未鲲(上海)科技服务有限公司 | Application program network environment detection method, device, equipment and storage medium |
| CN113746821A (en) * | 2021-08-24 | 2021-12-03 | 深圳Tcl新技术有限公司 | Intelligent device control method and device, storage medium and electronic device |
-
2021
- 2021-12-30 CN CN202111658088.2A patent/CN114338461A/en active Pending
Patent Citations (5)
| Publication number | Priority date | Publication date | Assignee | Title |
|---|---|---|---|---|
| US6397255B1 (en) * | 1998-12-23 | 2002-05-28 | At&T Corp. | Method and apparatus for providing intelligent network services |
| CN107332739A (en) * | 2017-07-28 | 2017-11-07 | 广东欧珀移动通信有限公司 | Network detection method, network detection device and intelligent terminal |
| CN107360059A (en) * | 2017-07-28 | 2017-11-17 | 广东欧珀移动通信有限公司 | Network detecting method, network detection means and intelligent terminal |
| CN113472607A (en) * | 2021-06-29 | 2021-10-01 | 未鲲(上海)科技服务有限公司 | Application program network environment detection method, device, equipment and storage medium |
| CN113746821A (en) * | 2021-08-24 | 2021-12-03 | 深圳Tcl新技术有限公司 | Intelligent device control method and device, storage medium and electronic device |
Cited By (1)
| Publication number | Priority date | Publication date | Assignee | Title |
|---|---|---|---|---|
| WO2023221947A1 (en) * | 2022-05-20 | 2023-11-23 | 阿里巴巴(中国)有限公司 | Data transmission method for cloud application, and computing device and computer storage medium |
Similar Documents
| Publication | Publication Date | Title |
|---|---|---|
| US10728168B2 (en) | Method for providing a connection of a client to an unmanaged service in a client-server remote access system | |
| CN109032706B (en) | Intelligent contract execution method, device, equipment and storage medium | |
| US8296786B2 (en) | Agent-based remote function execution | |
| CN108768730B (en) | Method and device for operating intelligent network card | |
| US8468124B2 (en) | Debugging workflows | |
| CN107493266B (en) | Communication system, method and device of embedded self-service terminal | |
| WO2019001074A1 (en) | Remote process calling method and apparatus, and computer device | |
| CN114205342A (en) | Routing method, electronic device, medium, and program product for service debugging | |
| CN113821352B (en) | A remote service calling method and device | |
| US10402307B2 (en) | System and method for providing runtime tracing for a web-based client accessing a transactional middleware platform using an extension interface | |
| KR102572013B1 (en) | Request processing method, apparatus, device and computer storage medium | |
| CN107315360A (en) | Remote control method and system of measuring instrument | |
| CN114338461A (en) | A network connection monitoring method and related equipment | |
| US10313450B2 (en) | Method for transparently connecting augmented network socket operations | |
| US20170264527A1 (en) | Diagnostic service for devices that employ a device agent | |
| CN113760693B (en) | Method and device for local debugging of microservice system | |
| CN109660573B (en) | Data transmission method and device | |
| CN112039749B (en) | Node js-based Internet of things equipment management method, system and storage medium | |
| WO2019122011A1 (en) | Computer system and method for extracting dynamic content from websites | |
| CN107368340A (en) | A kind of software automatic installation method and device | |
| CN105718360A (en) | JAVA management extension fetching component and JAVA management extension fetching component realizing method | |
| CN103259676A (en) | Method and device for fault diagnosis | |
| CN112583614B (en) | Host cluster management method, device and computer readable medium | |
| CN120315911B (en) | Micro-service calling method, device and equipment based on aggregation deployment | |
| CN117762782A (en) | Service testing method, device, equipment and storage medium |
Legal Events
| Date | Code | Title | Description |
|---|---|---|---|
| PB01 | Publication | ||
| PB01 | Publication | ||
| SE01 | Entry into force of request for substantive examination | ||
| SE01 | Entry into force of request for substantive examination | ||
| AD01 | Patent right deemed abandoned |
Effective date of abandoning: 20241122 |
|
| AD01 | Patent right deemed abandoned |