WO2019024381A1 - 服务发现方法、装置、计算机可读存储介质和计算机设备 - Google Patents
服务发现方法、装置、计算机可读存储介质和计算机设备 Download PDFInfo
- Publication number
- WO2019024381A1 WO2019024381A1 PCT/CN2017/116084 CN2017116084W WO2019024381A1 WO 2019024381 A1 WO2019024381 A1 WO 2019024381A1 CN 2017116084 W CN2017116084 W CN 2017116084W WO 2019024381 A1 WO2019024381 A1 WO 2019024381A1
- Authority
- WO
- WIPO (PCT)
- Prior art keywords
- service
- connection
- server
- code
- port number
- 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.)
- Ceased
Links
Images
Classifications
-
- H—ELECTRICITY
- H04—ELECTRIC COMMUNICATION TECHNIQUE
- H04L—TRANSMISSION OF DIGITAL INFORMATION, e.g. TELEGRAPHIC COMMUNICATION
- H04L65/00—Network arrangements, protocols or services for supporting real-time applications in data packet communication
- H04L65/40—Support for services or applications
Definitions
- the present application relates to the field of communications technologies, and in particular, to a service discovery method, apparatus, computer readable storage medium, and computer device.
- the client For systems that include both a server and a client, the client usually needs to discover and connect to the server.
- the existing configuration-free service discovery protocol includes Apple Bonjour and SSDP (Simple Service Discovery Protocol).
- the client can obtain information such as the service IP address and port number of the server based on the protocol, and based on the obtained information. Establishing a connection with the server, but such a protocol is usually implemented based on the UDP (User Datagram Protocol) multicast or broadcast in the LAN.
- UDP User Datagram Protocol
- the user can also configure the service IP and port number on the client.
- the client can establish a connection with the server based on the information configured by the user. However, in this way, the implementation is cumbersome and not easy enough in practical applications.
- the present application provides a service discovery method, a device, a computer readable storage medium, and a computer device to solve the problem that the service discovery cannot be performed across network segments in the related art, and the actual application is not simple enough.
- the application provides a service discovery method, where the method is applied to a server, including:
- a connection is established with the client based on the connection request.
- the application provides a service discovery method, where the method is applied to a client, including:
- connection code of the server input by the user; wherein the connection code is encoded by the server according to the service IP and port number of the server;
- the application provides a service discovery device, where the device is applied to a server, including:
- a generating unit configured to generate a connection code according to a service IP address and a port number of the server
- a notification unit configured to display the generated connection code on the user interface, so that the client parses the connection code input by the user to obtain the service IP and port number;
- a establishing unit configured to establish a connection with the client based on the connection request when receiving the connection request sent by the client based on the service IP and the port number.
- the application provides a service discovery device, where the device is applied to a client, including:
- An obtaining unit configured to obtain a connection code of the server input by the user; wherein the connection code is encoded by the server according to the service IP and port number of the server;
- a parsing unit configured to parse the connection code, and obtain a service IP and a port number of the server
- a sending unit configured to send a connection request to the server according to the service IP and the port number, so that the server establishes a connection with the client based on the connection request.
- the present application provides a computer readable storage medium having stored thereon a computer program, the program being implemented by a processor to implement the steps of the above method.
- the present application provides a computer device comprising a memory, a processor, and a computer program stored on the memory and executable on the processor, the processor executing the above method.
- the server can encode the service IP address and port number of the local device according to a certain coding rule, generate a corresponding connection code and notify the user, and the client can directly obtain the service by parsing the connection code input by the user.
- the service IP and port number of the end Compared with the related art, the client does not need to perform service discovery through UDP multicast or broadcast in the technical solution of the present application. Therefore, whether the client is in the same network segment as the server does not affect the service discovery of the client. That is, service discovery across network segments can be achieved.
- the user only needs to know the connection code of a server.
- the connection code is input into the client, so that the client performs directed service discovery for the server, which simplifies the user's operation process compared with the related technology, and is more convenient in practical applications.
- Figure 1 is a system architecture diagram including a server and a client;
- FIG. 2 is a flowchart of a service discovery method according to an exemplary embodiment of the present application.
- FIG. 3 is a flowchart of another service discovery method according to an exemplary embodiment of the present application.
- FIG. 4 is a hardware structural diagram of a device where a service discovery device is located according to an exemplary embodiment of the present application
- FIG. 5 is a hardware structural diagram of another device where a service discovery device is shown in an exemplary embodiment of the present application.
- FIG. 6 is a block diagram of a service discovery apparatus according to an exemplary embodiment of the present application.
- FIG. 7 is a block diagram of another service discovery apparatus according to an exemplary embodiment of the present application.
- first, second, third, etc. may be used to describe various information in this application, such information should not be limited to these terms. These terms are only used to distinguish the same type of information from each other.
- first information may also be referred to as the second information without departing from the scope of the present application.
- second information may also be referred to as the first information.
- word "if” as used herein may be interpreted as "when” or "when” or "in response to determination.”
- FIG. 1 is a system architecture diagram including a server and a client.
- the client may be a mobile phone, a user PC, or the like, and the server may be a network printer, an AirPlay receiver, or the like.
- the client needs to discover and connect to the server, that is, the client needs to obtain information such as the service IP address and port number of the server, and establish a connection with the server based on the obtained information to perform subsequent user services. deal with.
- the client can obtain information such as the service IP address and port number of the server based on the configuration-free service discovery protocol (for example, Apple Bonjour, SSDP, etc.), and establish a connection with the server according to the obtained information.
- the configuration-free service discovery protocol for example, Apple Bonjour, SSDP, etc.
- this type of protocol is usually implemented based on the UDP (User Datagram Protocol) multicast or broadcast in the local area network.
- UDP User Datagram Protocol
- the client can only perform service discovery for the server in the same local area network.
- the client can discover the multiple servers and provide the user with the server to be connected, and then select the service based on the server.
- Information such as IP and port number is connected to the server, which is obviously not easy enough in practical applications.
- the user can also configure the service IP address and port number of the server on the client, and the client can establish a connection with the server based on the information configured by the user.
- the user needs to obtain the service IP and port number and other information.
- the implementation is cumbersome and not easy enough in practical applications.
- FIG. 2 is a flowchart of a service discovery method according to an exemplary embodiment of the present application.
- the method can be applied to the server shown in Figure 1, and includes the following steps:
- Step 201 Encoding according to the service IP and port number of the server to generate a connection code.
- Step 202 Display the generated connection code on the user interface, so that the client parses the connection code input by the user to obtain the service IP and port number.
- Step 203 When receiving the connection request sent by the client based on the service IP and the port number, establish a connection with the client based on the connection request.
- the user may preset an encoding rule for the IP address and the port number, for example, converting the IP address into a binary value for encoding, and agreeing the correspondence between the port number and the binary value to encode the binary value corresponding to the port number. Convert the encoded binary value to a decimal value and display it to the user.
- the server can encode the service IP address and port number of the local device according to the coding rules set by the user, and generate a corresponding connection code.
- the server can notify the user of the generated connection code. Specifically, the server may display the generated connection code on the user interface for the user to view, so that the user can obtain the connection code generated by the server; or the server can send a text message, an email, etc. to the user, thereby The user can know the connection code generated by the server by viewing these short messages, emails, and the like.
- connection code generated by the server After the user obtains the connection code generated by the server, the user can input the connection code through the user interface provided by the client, so that the client resolves the connection code to obtain the service IP address and port number of the server, that is, completes the service discovery for the server. .
- the client can send a connection request to the server based on the obtained service IP and port number.
- the server may establish a connection with the client based on the connection request for subsequent user service processing.
- the server can encode the service IP address and port number of the local device according to a certain coding rule, generate a corresponding connection code, and notify the user, and the client can directly obtain the service by parsing the connection code input by the user.
- the service IP and port number of the end Compared with the related art, the client does not need to perform service discovery through UDP multicast or broadcast in the technical solution of the present application. Therefore, whether the client is in the same network segment as the server does not affect the service discovery of the client. That is, service discovery across network segments can be achieved.
- connection code of a certain server In addition, the user only needs to know the connection code of a certain server, and input the connection code into the client, so that the client performs targeted service discovery for the server, which simplifies the operation process of the user compared with the related technology. It is easier to use in practical applications.
- FIG. 3 is a flowchart of another service discovery method according to an exemplary embodiment of the present application.
- the method can be applied to the client shown in Figure 1, and includes the following steps:
- Step 301 Acquire a connection code of the server input by the user, where the connection code is encoded by the server according to the service IP and port number of the server.
- Step 302 Parse the connection code, and obtain a service IP and a port number of the server.
- Step 303 Send a connection request to the server according to the service IP and the port number, so that the server establishes a connection with the client based on the connection request.
- the user can select the server to be connected, and input the selected connection code of the server through the user interface provided by the client.
- the client may parse the connection code to obtain the service IP and port number of the server selected by the user, that is, complete the service discovery for the server.
- the client can send a connection request to the server selected by the user based on the obtained service IP and port number.
- the server may establish a connection with the client based on the connection request for subsequent user service processing.
- the server can encode the service IP address and port number of the local device according to a certain coding rule, generate a corresponding connection code, and notify the user, and the client can directly obtain the service by parsing the connection code input by the user.
- the service IP and port number of the end Compared with the related art, the client does not need to pass UDP multicast in the technical solution of the present application. Or broadcast to perform service discovery. Therefore, whether the client is in the same network segment as the server does not affect the service discovery of the client, that is, service discovery across network segments can be implemented.
- connection code of a certain server In addition, the user only needs to know the connection code of a certain server, and input the connection code into the client, so that the client performs targeted service discovery for the server, which simplifies the operation process of the user compared with the related technology. It is easier to use in practical applications.
- the server 1 can follow the preset coding rule.
- the IP address 192.168.2.3 and the port number 8088 are encoded to generate a corresponding connection code.
- the user preset encoding rules are as follows: convert the service IP to a binary value. If the service IP is an IPv4 address, the binary value is used as the first 32 bits of the connection code. If the service IP is an IPv6 address, the binary is used. The value is used as the first 128 bits of the connection code; the agreed binary value 00 corresponds to the port number 8080, the binary value 01 corresponds to the port number 8088, the binary value 10 corresponds to the port number 8888, the binary value 11 corresponds to the port number 9999, and the port number corresponds to The binary value is used as the last 2 bits of the concatenated code.
- the server 1 after the server 1 encodes the service IP of the local machine, the generated connection code is 11000000101010000000001000000011, and after the port number is encoded, the generated connection code is 00.
- the server 1 can add the connection code corresponding to the port number to the connection code corresponding to the service IP, that is, the finally generated connection code is 1100000010101000000000100000001100.
- the connection code After the server 1 generates the connection code, the connection code can be displayed on the user interface for the user to view.
- the user can input the connection code through the user interface provided by the client 1.
- the client 1 can parse the connection code according to the above coding rule: the client can convert the first 32 bits of the connection code 11000000101010000000001000000011 as a binary value to an IP address 192.168.2.3, and determine the last 2 bits 00 as a binary.
- the port number corresponding to the value is 8080. That is, the client 1 can obtain the service IP of the server 1 as 192.168.2.3 and the port number is 8080 by parsing the connection code.
- connection code In order to reduce the number of bits of the connection code, it is convenient for the user to use the connection code.
- the server 1 encodes the service IP and the port number to obtain a binary value of 1100000010101000000000100000001100, the binary value can be converted into a decimal value of 12928944140 as a connection code.
- the client 1 may first convert the connection code into a binary value of 1100000010101000000000100000001100, and then parse the binary value according to the above coding rule.
- the client 1 After obtaining the service IP address and the port number, the client 1 can construct a connection request with the destination IP address of 192.168.2.3 and the destination port number of 8080 to be sent to the server 1. After receiving the connection request, server 1 can communicate with client 1 establish connection. Subsequently, the server 1 and the client 1 can perform data transmission through the established connection to implement user services.
- the server and client in the same network segment have the same network address in the IP address and different host addresses. Therefore, in practical applications, in order to reduce the number of bits of the connection code generated by encoding the service IP, it is convenient for the client to parse the connection code to obtain the service IP, and the server can encode the host address and port number of the service IP of the local machine to generate a connection. The code and notify the user of the generated connection code. After the user inputs the connection code through the user interface provided by the client in the same network segment as the server, the client can parse the connection code to obtain the host address and port number of the service IP. Subsequently, the client can add the network address of the local IP to the obtained host address to obtain the complete service IP.
- the subnet mask of the server 1 is 255.255.255.0
- the first 24 bits are the network address of the service IP, and the last 8 bits for the binary value obtained by the service IP conversion.
- the bit is the host address of the service IP.
- the server 1 can encode the host address of the service IP address of the local device, and the generated connection code is 00000011, and the connection code corresponding to the port number is added to the connection code corresponding to the host address of the service IP, that is, the finally generated connection code. Is 0000001100.
- the client 1 can add the first 24 bits of the binary value obtained by the local IP conversion to 110000001010100000000010. Before the first 8 bits of the connection code is 0901100, it is converted to the IP address 192.168.2.3 as the binary value 1100000010101000000000100000001100, that is, the client 1 can obtain the service IP of the server 1 as 192.168.2.3. At the same time, the client 1 can determine that the port number corresponding to the last two bits 00 of the connection code is 8080, that is, the client 1 can obtain the port number of the server 1 as 8080.
- the server and the client in the same network segment do not have the same network address and host address in the IP address, the server still needs to encode the complete service IP and port number to generate a connection code. Therefore, the client that is not in the same network segment as the server can parse the connection code and obtain the complete service IP and port number.
- the server can generate the above two connection codes and notify the user at the same time.
- the user can check whether the client and the server are in the same network segment before inputting the connection code through the user interface provided by the client. If the two are in the same network segment, the user can input the connection code generated by the server based on the service IP-based host address and port number in the client; if the two are not in the same network segment, the user can be at the client. Enter the connection code generated by the server based on the full service IP and port number.
- the client can determine whether the service IP obtained by parsing the connection code is a complete IP address by judging the number of digits of the connection code input by the user, for example, whether the connection code input by the user has 34 or 10 bits.
- the server when the server generates the connection code, it can also extend multiple bits in the connection code as the first security.
- the full code may add a 4-bit bit as the first security code before the connection code corresponding to the service IP, and the value of the 4-bit bit may be randomly generated by the server.
- the client when the client sends a connection request to the server based on the obtained service IP and port number, the client may add a security code obtained by parsing the connection code input by the user to the connection request as the second security code.
- the server may compare the first security code in the connection code generated by the server with the second security code in the connection request sent by the client. If the server compares the first security code with the second security code, it indicates that the client's connection request has been authorized, and the server can establish a connection with the client based on the connection request.
- connection code generated by the server 1 is 10110000001100, wherein the first 4 bits 1011 are the first security code, the middle 8 bits 00000011 correspond to the host address of the service IP, and the last 2 bits 00 Corresponding port number.
- the client 1 can parse the connection code input by the user, and obtain the service IP of the server 1 as 192.168.2.3, the port number is 8080, and the security code is 1011. Subsequently, the client 1 can send a connection request to the server 1 based on the service IP 192.168.2.3 and the port number 8080, and add the security code 1011 as the second security code in the connection request.
- the server 1 may compare the second security code 1011 in the connection request with the first security code 1011 in the connection code generated by itself. Since the first security code and the second security code are the same at this time, it is indicated that the connection request of the client 1 has been authorized, and the server 1 can establish a connection with the client 1 based on the connection request for subsequent user service processing.
- the display form of the connection code may also be pre-defined.
- the user can specify that the connection code is displayed in the form of a 6-digit decimal value, and the coding space of the connection code is 20 bits. It is assumed that the encoding rule set by the user includes: the first 4 bits are used as the first security code; the 2 bits after the first security code are used as the bit corresponding to the port number; and the remaining unused 14 bits are used as the service. The bit corresponding to the IP.
- the first 24 bits are the network address of the service IP for the binary value 11000000101010000000001000000011 obtained by the service IP conversion.
- the bit bit is the host address of the service IP.
- the server 1 can encode the 6-bit low-order network address, the 8-bit host address, and the port number, and obtain the binary value corresponding to the connection code of 10110000001000000011, as shown in Table 1 below:
- the server 1 can convert the binary value into a decimal value 721411 as a connection code displayed to the user, that is, the user can see that the connection code of the server 1 is 721411.
- the client 1 may first convert the connection code into a binary value of 10110000001000000011, and then parse the binary value according to the above coding rule.
- the client 1 adds the high-order network address of the local IP to the low-level network address and the host address of the server 1 obtained by parsing the binary value to obtain the complete service IP of the server 1. .
- the client 1 adds the first 18 bits of the binary value 11000000101010000000001100000100 obtained by the local IP to the parsed low-order network address 000010 and the host address 00000011.
- the binary value 11000000101010000000001000000011 is converted to the IP address 192.168.2.3, that is, the client 1 can obtain the service IP of the server 1 as 192.168.2.3. It can be seen that this method is suitable for servers and clients with the same high-level network address.
- the present application also provides an embodiment of the service discovery device.
- Embodiments of the service discovery device of the present application can be applied to both the server and the client.
- the device embodiment may be implemented by software, or may be implemented by hardware or a combination of hardware and software.
- the processor is located in the server or the client device to read the corresponding computer program instructions in the non-volatile memory into the memory.
- FIG. 4 a hardware structure diagram of the server where the service discovery device is located is shown in FIG. 5, which is a hardware structure diagram of the client where the service discovery device is located.
- the server device or the client device where the device is located in the embodiment may generally be based on the actual function discovered by the service. Including other hardware, we will not go into details here.
- FIG. 6 is a block diagram of a service discovery apparatus according to an exemplary embodiment of the present application.
- the apparatus 600 can be applied to the server shown in FIG. 4 , and includes:
- a generating unit 601 configured to generate a connection code according to a service IP address and a port number of the server
- the notification unit 602 is configured to display the generated connection code on the user interface, so that the client parses the connection code input by the user to obtain the service IP and the port number;
- the establishing unit 603 is configured to establish a connection with the client based on the connection request when receiving the connection request sent by the client based on the service IP and the port number.
- the generating unit 601 may include:
- a first generating subunit 6011 configured to encode the complete service IP and port number to generate a connection code
- a second generation subunit 6012 configured to encode a host address and a port number of the service IP to generate a connection code
- the third generation subunit 6013 is configured to encode the host address, the low-order network address, and the port number of the service IP to generate a connection code.
- the apparatus 600 may further include:
- the expansion unit 604 is configured to: when generating the connection code, extend the multi-bit bit in the connection code as the first security code;
- the comparing unit 605 is configured to compare the first security code with the second security code in the connection request when receiving the connection request sent by the client;
- the establishing unit 603 is further configured to establish a connection with the client based on the connection request when the first security code is the same as the second security code.
- FIG. 7 is a block diagram of another service discovery apparatus according to an exemplary embodiment of the present application.
- the apparatus 700 can be applied to the client shown in FIG. 5 , and includes:
- the obtaining unit 701 is configured to obtain a connection code of the server input by the user, where the connection code is encoded by the server according to the service IP and the port number of the server;
- the parsing unit 702 is configured to parse the connection code, and obtain a service IP and a port number of the server;
- the sending unit 703 is configured to send a connection request to the server according to the service IP and the port number, so that the server establishes a connection with the client based on the connection request.
- the parsing unit 702 can include:
- a first parsing subunit 7021 configured to use an IP address obtained by parsing the connection code as a service IP of the server;
- the second parsing subunit 7022 is configured to replace the host address of the local IP with the host address obtained by parsing the connection code, and use the replaced IP address as the service IP of the server; and/or
- the third parsing subunit is configured to replace the host address and the lower network address of the local IP with the host address and the lower network address obtained by parsing the connection code, and use the replaced IP address as the service IP of the server.
- the device embodiment since it basically corresponds to the method embodiment, reference may be made to the partial description of the method embodiment.
- the device embodiments described above are merely illustrative, wherein the units described as separate components may or may not be physically separate, and the components displayed as units may or may not be physical units, ie may be located A place, or it can be distributed to multiple network units. Some or all of the modules may be selected according to actual needs to achieve the objectives of the present application. Those of ordinary skill in the art can understand and implement without any creative effort.
- a computer readable storage medium having stored thereon a computer program, the program being implemented by a processor to implement the following method:
- a connection is established with the client based on the connection request.
- the generating the connection code according to the service IP address and the port number of the server may include:
- the host address, the lower network address, and the port number of the service IP are encoded to generate a connection code.
- the method may further include:
- connection code When generating the connection code, extending a multi-bit bit in the connection code as a first security code
- the first security code is the same as the second security code, establishing a connection with the client based on the connection request connection.
- the program is implemented by the processor to implement the following method:
- connection code of the server input by the user; wherein the connection code is encoded by the server according to the service IP and port number of the server;
- the obtaining the service IP of the server may include:
- the IP address obtained by parsing the connection code is used as the service IP of the server; and/or
- the host address and the lower network address of the local IP are replaced with the host address and the lower network address obtained by parsing the connection code, and the replaced IP address is used as the service IP of the server.
- a computer apparatus including a memory, a processor, and a computer program stored on the memory and executable on the processor, and the processor may implement the following steps when executing the program :
- a connection is established with the client based on the connection request.
- the processor when the processor performs encoding according to the service IP and port number of the server to generate a connection code, the following steps may be implemented:
- the host address, the lower network address, and the port number of the service IP are encoded to generate a connection code.
- the processor may further implement the following steps when executing the program:
- connection code When generating the connection code, extending a multi-bit bit in the connection code as a first security code
- the first security code is the same as the second security code, establishing a connection with the client based on the connection request.
- the processor may implement the following steps when executing the program:
- connection code of the server input by the user; wherein the connection code is encoded by the server according to the service IP and port number of the server;
- the IP address obtained by parsing the connection code is used as the service IP of the server; and/or
- the host address and the lower network address of the local IP are replaced with the host address and the lower network address obtained by parsing the connection code, and the replaced IP address is used as the service IP of the server.
Landscapes
- Engineering & Computer Science (AREA)
- Multimedia (AREA)
- Computer Networks & Wireless Communication (AREA)
- Signal Processing (AREA)
- Data Exchanges In Wide-Area Networks (AREA)
Abstract
本申请提供一种服务发现方法、装置、计算机可读存储介质和计算机设备,包括:服务端根据其服务IP和端口号进行编码生成连接码;服务端将生成的连接码显示在用户界面上,以使客户端解析用户输入的所述连接码获取所述服务IP和端口号;服务端在接收到所述客户端基于所述服务IP和端口号发送的连接请求时,基于所述连接请求与所述客户端建立连接。本申请技术方案可以实现跨网段的服务发现,且在实际应用中较为简便。
Description
本申请涉及通信技术领域,尤其涉及一种服务发现方法、装置、计算机可读存储介质和计算机设备。
对于包括服务端与客户端的系统而言,客户端通常需要发现并连接至服务端。现有的免配置服务发现协议包括Apple Bonjour以及SSDP(Simple Service Discovery Protocol,简单服务发现协议)等,客户端可以基于这类协议获取服务端的服务IP和端口号等信息,并基于获取到的信息与服务端建立连接,但这类协议通常基于局域网内的UDP(User Datagram Protocol,用户数据报协议)组播或广播的方式实现,存在无法跨网段进行服务发现、实际应用中不够简便的问题。或者,用户也可以在客户端配置服务IP和端口号等信息,客户端可以基于用户配置的信息与服务端建立连接,但采用这种方式,实现较为繁琐,在实际应用中也不够简便。
发明内容
有鉴于此,本申请提供一种服务发现方法、装置、计算机可读存储介质和计算机设备,以解决相关技术中无法跨网段进行服务发现、实际应用中不够简便的问题。
具体地,本申请是通过如下技术方案实现的:
第一方面,本申请提供一种服务发现方法,所述方法应用于服务端,包括:
根据服务端的服务IP和端口号进行编码生成连接码;
将生成的连接码显示在用户界面上,以使客户端解析用户输入的所述连接码获取所述服务IP和端口号;
在接收到所述客户端基于所述服务IP和端口号发送的连接请求时,基于所述连接请求与所述客户端建立连接。
第二方面,本申请提供一种服务发现方法,所述方法应用于客户端,包括:
获取用户输入的服务端的连接码;其中,所述连接码由所述服务端根据所述服务端的服务IP和端口号进行编码生成;
解析所述连接码,获取所述服务端的服务IP和端口号;
基于所述服务IP和端口号,向所述服务端发送连接请求,以使所述服务端基于所述连接请求与客户端之间建立连接。
第三方面,本申请提供一种服务发现装置,所述装置应用于服务端,包括:
生成单元,用于根据服务端的服务IP和端口号进行编码生成连接码;
通知单元,用于将生成的连接码显示在用户界面上,以使客户端解析用户输入的所述连接码获取所述服务IP和端口号;
建立单元,用于在接收到所述客户端基于所述服务IP和端口号发送的连接请求时,基于所述连接请求与所述客户端建立连接。
第四方面,本申请提供一种服务发现装置,所述装置应用于客户端,包括:
获取单元,用于获取用户输入的服务端的连接码;其中,所述连接码由所述服务端根据所述服务端的服务IP和端口号进行编码生成;
解析单元,用于解析所述连接码,获取所述服务端的服务IP和端口号;
发送单元,用于基于所述服务IP和端口号,向所述服务端发送连接请求,以使所述服务端基于所述连接请求与客户端之间建立连接。
第五方面,本申请提供一种计算机可读存储介质,其上存储有计算机程序,所述程序被处理器执行时实现上述方法的步骤。
第六方面,本申请提供一种计算机设备,包括存储器、处理器及存储在存储器上并可在处理器上运行的计算机程序,所述处理器执行上述方法。
分析上述技术方案可知,服务端可以将本机的服务IP和端口号按照一定的编码规则进行编码,生成对应的连接码并通知给用户,客户端则可以通过解析用户输入的连接码直接获取服务端的服务IP和端口号。与相关技术相比,由于本申请技术方案中客户端不需要通过UDP组播或广播进行服务发现,因此客户端是否与服务端在同一网段中并不会对客户端进行服务发现造成影响,即可以实现跨网段的服务发现。此外,用户仅需获知某一服务端的连接码,
并将该连接码输入至客户端中,使客户端针对该服务端进行定向的服务发现,与相关技术相比简化了用户的操作过程,在实际应用中更为简便。
图1是包括服务端与客户端的系统架构图;
图2是本申请一示例性实施例示出的一种服务发现方法的流程图;
图3是本申请一示例性实施例示出的另一种服务发现方法的流程图;
图4是本申请一示例性实施例示出的一种服务发现装置所在设备的硬件结构图;
图5是本申请一示例性实施例示出的另一种服务发现装置所在设备的硬件结构图;
图6是本申请一示例性实施例示出的一种服务发现装置的框图;
图7是本申请一示例性实施例示出的另一种服务发现装置的框图。
这里将详细地对示例性实施例进行说明,其示例表示在附图中。下面的描述涉及附图时,除非另有表示,不同附图中的相同数字表示相同或相似的要素。以下示例性实施例中所描述的实施方式并不代表与本申请相一致的所有实施方式。相反,它们仅是与如所附权利要求书中所详述的、本申请的一些方面相一致的装置和方法的例子。
在本申请使用的术语是仅仅出于描述特定实施例的目的,而非旨在限制本申请。在本申请和所附权利要求书中所使用的单数形式的“一种”、“所述”和“该”也旨在包括多数形式,除非上下文清楚地表示其他含义。还应当理解,本文中使用的术语“和/或”是指并包含一个或多个相关联的列出项目的任何或所有可能组合。
应当理解,尽管在本申请可能采用术语第一、第二、第三等来描述各种信息,但这些信息不应限于这些术语。这些术语仅用来将同一类型的信息彼此区分开。例如,在不脱离本申请范围的情况下,第一信息也可以被称为第二信息,类似地,第二信息也可以被称为第一信息。取决于语境,如在此所使用的词语“如果”可以被解释成为“在……时”或“当……时”或“响应于确定”。
请参考图1,为包括服务端与客户端的系统架构图,其中,客户端可以是手机、用户PC等设备,服务端可以是网络打印机、AirPlay接收器等设备。对于这类系统而言,客户端需要发现并连接至服务端,即客户端需要获取服务端的服务IP和端口号等信息,并基于获取到的信息与服务端建立连接,以进行后续的用户业务处理。
相关技术中,客户端可以基于免配置服务发现协议(例如:Apple Bonjour、SSDP等)获取服务端的服务IP和端口号等信息,并根据获取到的信息与服务端建立连接。然而,这类协议通常基于局域网内的UDP(User Datagram Protocol,用户数据报协议)组播或广播的方式实现,即采用这种方式,客户端仅可以针对同一局域网内的服务端进行服务发现。此外,如图1所示,如果同一局域网内存在多个服务端,则客户端可以发现这多个服务端,并提供给用户从中选择需要连接的服务端,再基于所选择的该服务端的服务IP和端口号等信息与该服务端建立连接,在实际应用中显然不够简便。
或者,用户也可以在客户端配置服务端的服务IP和端口号等信息,客户端可以基于用户配置的信息与服务端建立连接。但采用这种方式,需要用户自行获取服务IP和端口号等信息,对于IP地址经常发生变化的服务端而言,实现较为繁琐,在实际应用中也不够简便。
请参考图2,为本申请一示例性实施例示出的一种服务发现方法的流程图。该方法可以应用于图1所示的服务端中,包括以下步骤:
步骤201:根据服务端的服务IP和端口号进行编码生成连接码。
步骤202:将生成的连接码显示在用户界面上,以使客户端解析用户输入的所述连接码获取所述服务IP和端口号。
步骤203:在接收到所述客户端基于所述服务IP和端口号发送的连接请求时,基于所述连接请求与所述客户端建立连接。
在本实施例中,用户可以预先设置针对IP地址和端口号的编码规则,例如将IP地址转换为二进制数值进行编码,约定端口号与二进制数值的对应关系以将端口号对应的二进制数值进行编码,将编码得到的二进制数值转换为十进制数值展示给用户等。服务端可以按照用户设置的编码规则,将本机的服务IP和端口号进行编码,生成对应的连接码。
服务端在生成连接码后,可以将生成的连接码通知给用户。具体地,服务端可以将生成的连接码显示在用户界面上,供用户查看,从而使用户可以获知到服务端生成的连接码;或者,服务端也可以向用户发送短信、邮件等,从而使用户可以通过查看这些短信、邮件等获知到服务端生成的连接码。
用户在获知到服务端生成的连接码后,可以通过客户端提供的用户界面输入该连接码,从而使客户端解析该连接码获取服务端的服务IP和端口号,即完成针对该服务端的服务发现。
后续,客户端可以基于获取到的服务IP和端口号向服务端发送连接请求。服务端在接收到该连接请求后,可以基于该连接请求与客户端建立连接,以进行后续的用户业务处理。
由上述实施例可见,服务端可以将本机的服务IP和端口号按照一定的编码规则进行编码,生成对应的连接码并通知给用户,客户端则可以通过解析用户输入的连接码直接获取服务端的服务IP和端口号。与相关技术相比,由于本申请技术方案中客户端不需要通过UDP组播或广播进行服务发现,因此客户端是否与服务端在同一网段中并不会对客户端进行服务发现造成影响,即可以实现跨网段的服务发现。此外,用户仅需获知某一服务端的连接码,并将该连接码输入至客户端中,使客户端针对该服务端进行定向的服务发现,与相关技术相比简化了用户的操作过程,在实际应用中更为简便。
与图2所示的实施例相应地,请参考图3,为本申请一示例性实施例示出的另一种服务发现方法的流程图。该方法可以应用于图1所示的客户端中,包括以下步骤:
步骤301:获取用户输入的服务端的连接码;其中,所述连接码由所述服务端根据所述服务端的服务IP和端口号进行编码生成。
步骤302:解析所述连接码,获取所述服务端的服务IP和端口号。
步骤303:基于所述服务IP和端口号,向所述服务端发送连接请求,以使所述服务端基于所述连接请求与客户端之间建立连接。
在本实施例中,当同一局域网内存在多个服务端时,用户可以选择需要连接的服务端,并通过客户端提供的用户界面,输入所选择的该服务端的连接码。
客户端在获取到用户输入的连接码后,可以对该连接码进行解析,获取用户选择的服务端的服务IP和端口号,即完成针对该服务端的服务发现。
后续,客户端可以基于获取到的服务IP和端口号,向用户选择的服务端发送连接请求。该服务端在接收到该连接请求后,可以基于该连接请求与客户端建立连接,以进行后续的用户业务处理。
由上述实施例可见,服务端可以将本机的服务IP和端口号按照一定的编码规则进行编码,生成对应的连接码并通知给用户,客户端则可以通过解析用户输入的连接码直接获取服务端的服务IP和端口号。与相关技术相比,由于本申请技术方案中客户端不需要通过UDP组播
或广播进行服务发现,因此客户端是否与服务端在同一网段中并不会对客户端进行服务发现造成影响,即可以实现跨网段的服务发现。此外,用户仅需获知某一服务端的连接码,并将该连接码输入至客户端中,使客户端针对该服务端进行定向的服务发现,与相关技术相比简化了用户的操作过程,在实际应用中更为简便。
以图1所示的客户端1与服务端1为例,假设服务端1用于提供服务的服务IP为192.168.2.3,端口号为8088,则服务端1可以按照预设的编码规则,将IP地址192.168.2.3和端口号8088进行编码,生成对应的连接码。
假设用户预先设置的编码规则如下:将服务IP转换为二进制数值,如果服务IP为IPv4地址,则将该二进制数值作为连接码的前32位比特位,如果服务IP为IPv6地址,则将该二进制数值作为连接码的前128位比特位;约定二进制数值00对应端口号8080,二进制数值01对应端口号8088,二进制数值10对应端口号8888,二进制数值11对应端口号9999,并将端口号对应的二进制数值作为连接码的后2位比特位。
按照上述编码规则,服务端1在将本机的服务IP进行编码后,生成的连接码为11000000101010000000001000000011,而在将端口号进行编码后,生成的连接码为00。服务端1可以将端口号对应的连接码添加至服务IP对应的连接码之后,即最终生成的连接码为1100000010101000000000100000001100。服务端1在生成该连接码后,可以将该连接码显示在用户界面上,以供用户查看。
用户在获知到服务端1生成的上述连接码后,可以通过客户端1提供的用户界面输入该连接码。客户端1可以按照上述编码规则对该连接码进行解析:客户端可以将该连接码的前32位比特位11000000101010000000001000000011作为二进制数值转换为IP地址192.168.2.3,并确定后2位比特位00作为二进制数值对应的端口号为8080,即客户端1通过解析该连接码可以获取服务端1的服务IP为192.168.2.3,端口号为8080。
为了减少连接码的位数,便于用户使用连接码,服务端1在对服务IP和端口号进行编码得到二进制数值1100000010101000000000100000001100后,可以将该二进制数值转换为十进制数值12928944140作为连接码。客户端1在获取到用户输入的连接码12928944140后,可以先将该连接码转换为二进制数值1100000010101000000000100000001100,再按照上述编码规则对该二进制数值进行解析。
客户端1在获取到上述服务IP和端口号后,可以构造目的IP地址为192.168.2.3,目的端口号为8080的连接请求发送给服务端1。服务端1在接收到该连接请求后,即可与客户端1
建立连接。后续,服务端1与客户端1之间可以通过建立的连接进行数据传输,实现用户业务。
通常,在同一网段中的服务端和客户端,其IP地址中的网络地址相同,主机地址不同。因此在实际应用中,为了减少对服务IP进行编码生成的连接码的位数,便于客户端解析连接码获取服务IP,服务端可以将本机的服务IP的主机地址和端口号进行编码生成连接码,并将生成的连接码通知给用户。用户在通过与该服务端在同一网段中的客户端提供的用户界面输入该连接码后,该客户端可以解析该连接码,获取服务IP的主机地址和端口号。后续,该客户端可以将本机IP的网络地址添加至获取到的主机地址之前,以获取完整的服务IP。
继续以上述举例为例,假设服务端1的子网掩码为255.255.255.0,则对于该服务IP转换得到的二进制数值而言,前24位比特位为该服务IP的网络地址,后8位比特位则为该服务IP的主机地址。服务端1可以将本机的服务IP的主机地址进行编码,生成的连接码为00000011,并将端口号对应的连接码添加至服务IP的主机地址对应的连接码之后,即最终生成的连接码为0000001100。
假设客户端1与服务端1在同一网段中,则客户端1在获取到用户输入的上述连接码后,可以将本机IP转换得到的二进制数值的前24位比特位110000001010100000000010,添加至该连接码的前8位比特位0000001100之前,作为二进制数值1100000010101000000000100000001100转换为IP地址192.168.2.3,即客户端1可以获取服务端1的服务IP为192.168.2.3。同时,客户端1可以确定该连接码的后2位比特位00对应的端口号为8080,即客户端1可以获取服务端1的端口号为8080。
另一方面,由于不在同一网段中的服务端和客户端,其IP地址中的网络地址和主机地址均不相同,因此服务端仍需将完整的服务IP和端口号进行编码生成连接码,从而使与该服务端不在同一网段中的客户端可以解析该连接码,获取完整的服务IP和端口号。
当然,服务端可以同时生成上述两种连接码并通知给用户,用户可以在通过客户端提供的用户界面输入连接码前,检查该客户端与服务端是否在同一网段中。如果两者在同一网段中,则用户可以在该客户端中输入服务端基于服务IP的主机地址和端口号生成的连接码;如果两者不在同一网段中,则用户可以在该客户端中输入服务端基于完整的服务IP和端口号生成的连接码。客户端则可以通过判断用户输入的连接码位数的多少,例如用户输入的连接码有34位还是10位,来判断通过解析该连接码得到的服务IP是否为完整的IP地址。
出于安全考虑,服务端在生成连接码时,还可以在连接码中扩展多位比特位作为第一安
全码,例如可以在服务IP对应的连接码之前添加4位比特位作为第一安全码,这4位比特位的数值可以由服务端随机生成。相应地,客户端在基于获取到的服务IP和端口号向服务端发送连接请求时,可以将解析用户输入的连接码获取到的安全码添加至该连接请求中作为第二安全码。
服务端在接收到客户端发送的连接请求时,可以将自身生成的连接码中的第一安全码与客户端发送的连接请求中的第二安全码进行比较。如果服务端比较出第一安全码与第二安全码相同,则说明该客户端的连接请求已通过授权,服务端可以基于该连接请求与客户端建立连接。
继续以上述举例为例,假设服务端1生成的连接码为10110000001100,其中前4位比特位1011为第一安全码,中间8位比特位00000011对应服务IP的主机地址,后2位比特位00对应端口号。
假设客户端1与服务端1在同一网段中,则客户端1可以解析用户输入的上述连接码,获取服务端1的服务IP为192.168.2.3,端口号为8080,且安全码为1011。后续,客户端1可以基于服务IP192.168.2.3和端口号8080向服务端1发送连接请求,并在该连接请求中添加安全码1011作为第二安全码。
服务端1在接收到客户端1发送的连接请求后,可以将该连接请求中的第二安全码1011,与自身生成的连接码中的第一安全码1011进行比较。由于此时第一安全码和第二安全码相同,因此说明客户端1的连接请求已通过授权,服务端1可以基于该连接请求与客户端1建立连接,以进行后续的用户业务处理。
在另一种实现方式中,也可以预先规定连接码的展示形式。举例来说,用户可以规定连接码以6位十进制数值的形式展示,则此时连接码的编码空间为20位比特位。假设用户设置的编码规则包括:将前4位比特位作为第一安全码;将第一安全码之后的2位比特位作为端口号对应的比特位;将剩余未使用的14位比特位作为服务IP对应的比特位。
继续以上述举例为例,假设服务端1的子网掩码为255.255.255.0,则对于该服务IP转换得到的二进制数值11000000101010000000001000000011而言,前24位比特位为该服务IP的网络地址,后8位比特位则为该服务IP的主机地址。此时,服务端1可以将6位低位网络地址、8位主机地址和端口号进行编码,得到连接码对应的二进制数值为10110000001000000011,如下表1所示:
| 第一安全码 | 端口号 | 低位网络地址 | 主机地址 |
| 1011 | 00 | 000010 | 00000011 |
表1
后续,服务端1可以将该二进制数值转换为十进制数值721411作为展示给用户的连接码,即用户可以查看到服务端1的连接码为721411。客户端1在获取到用户输入的连接码721411后,可以先将该连接码转换为二进制数值10110000001000000011,再按照上述编码规则对该二进制数值进行解析。
需要说明的是,此时客户端1会将本机IP的高位网络地址,添加至解析该二进制数值得到的服务端1的低位网络地址和主机地址之前,以获取服务端1的完整的服务IP。假设客户端1的本机IP为192.168.3.4,则客户端1会将本机IP转换得到的二进制数值11000000101010000000001100000100的前18位比特位,添加至解析得到的低位网络地址000010和主机地址00000011之前,作为二进制数值11000000101010000000001000000011转换为IP地址192.168.2.3,即客户端1可以获取服务端1的服务IP为192.168.2.3。由此可见,这种方式适用于高位网络地址相同的服务端和客户端。
当然,也可以预留多位比特位用于其他用途,本申请不作特殊限制。
与前述服务发现方法的实施例相对应,本申请还提供了服务发现装置的实施例。
本申请服务发现装置的实施例可以应用在服务端和客户端上。装置实施例可以通过软件实现,也可以通过硬件或者软硬件结合的方式实现。以软件实现为例,作为一个逻辑意义上的装置,是通过其所在服务端设备或客户端设备的处理器将非易失性存储器中对应的计算机程序指令读取到内存中运行形成的。从硬件层面而言,如图4所示,为本申请服务发现装置所在服务端的一种硬件结构图,如图5所示,为本申请服务发现装置所在客户端的一种硬件结构图。除了图4和图5所示的处理器、内存、网络接口、以及非易失性存储器之外,实施例中装置所在的服务端设备或客户端设备通常根据该服务发现的实际功能,还可以包括其他硬件,对此不再赘述。
请参考图6,为本申请一示例性实施例示出的一种服务发现装置的框图,该装置600可以应用在图4所示的服务端上,包括:
生成单元601,用于根据服务端的服务IP和端口号进行编码生成连接码;
通知单元602,用于将生成的连接码显示在用户界面上,以使客户端解析用户输入的所述连接码获取所述服务IP和端口号;
建立单元603,用于在接收到所述客户端基于所述服务IP和端口号发送的连接请求时,基于所述连接请求与所述客户端建立连接。
在一个可选的实施例中,所述生成单元601可以包括:
第一生成子单元6011,用于将完整的所述服务IP和端口号进行编码生成连接码;和/或
第二生成子单元6012,用于将所述服务IP的主机地址和端口号进行编码生成连接码;和/或
第三生成子单元6013,用于将所述服务IP的主机地址、低位网络地址和端口号进行编码生成连接码。
在另一个可选的实施例中,所述装置600还可以包括:
扩展单元604,用于在生成所述连接码时,在所述连接码中扩展多位比特位作为第一安全码;
比较单元605,用于在接收到客户端发送的连接请求时,将所述第一安全码与所述连接请求中的第二安全码进行比较;
所述建立单元603还可以用于当所述第一安全码与所述第二安全码相同时,基于所述连接请求与所述客户端建立连接。
请参考图7,为本申请一示例性实施例示出的另一种服务发现装置的框图,该装置700可以应用在图5所示的客户端上,包括:
获取单元701,用于获取用户输入的服务端的连接码;其中,所述连接码由所述服务端根据所述服务端的服务IP和端口号进行编码生成;
解析单元702,用于解析所述连接码,获取所述服务端的服务IP和端口号;
发送单元703,用于基于所述服务IP和端口号,向所述服务端发送连接请求,以使所述服务端基于所述连接请求与客户端之间建立连接。
在一个可选的实施例中,所述解析单元702可以包括:
第一解析子单元7021,用于将解析所述连接码得到的IP地址作为所述服务端的服务IP;和/或
第二解析子单元7022,用于将本机IP的主机地址替换为解析所述连接码得到的主机地址,并将替换后的IP地址作为所述服务端的服务IP;和/或
第三解析子单元,用于将本机IP的主机地址和低位网络地址替换为解析所述连接码得到的主机地址和低位网络地址,并将替换后的IP地址作为所述服务端的服务IP。
上述装置中各个单元的功能和作用的实现过程具体详见上述方法中对应步骤的实现过程,在此不再赘述。
对于装置实施例而言,由于其基本对应于方法实施例,所以相关之处参见方法实施例的部分说明即可。以上所描述的装置实施例仅仅是示意性的,其中所述作为分离部件说明的单元可以是或者也可以不是物理上分开的,作为单元显示的部件可以是或者也可以不是物理单元,即可以位于一个地方,或者也可以分布到多个网络单元上。可以根据实际的需要选择其中的部分或者全部模块来实现本申请方案的目的。本领域普通技术人员在不付出创造性劳动的情况下,即可以理解并实施。
在本申请一示例性实施例中,提供一种计算机可读存储介质,其上存储有计算机程序,所述程序被处理器执行时实现如下方法:
根据服务端的服务IP和端口号进行编码生成连接码;
将生成的连接码显示在用户界面上,以使客户端解析用户输入的所述连接码获取所述服务IP和端口号;
在接收到所述客户端基于所述服务IP和端口号发送的连接请求时,基于所述连接请求与所述客户端建立连接。
在一个可选的实施例中,所述根据服务端的服务IP和端口号进行编码生成连接码,可以包括:
将完整的所述服务IP和端口号进行编码生成连接码;和/或
将所述服务IP的主机地址和端口号进行编码生成连接码;和/或
将所述服务IP的主机地址、低位网络地址和端口号进行编码生成连接码。
在另一个可选的实施例中,所述方法还可以包括:
在生成所述连接码时,在所述连接码中扩展多位比特位作为第一安全码;
在接收到客户端发送的连接请求时,将所述第一安全码与所述连接请求中的第二安全码进行比较;
如果所述第一安全码与所述第二安全码相同,则基于所述连接请求与所述客户端建立
连接。
在另一个可选的实施例中,所述程序被处理器执行时实现如下方法:
获取用户输入的服务端的连接码;其中,所述连接码由所述服务端根据所述服务端的服务IP和端口号进行编码生成;
解析所述连接码,获取所述服务端的服务IP和端口号;
基于所述服务IP和端口号,向所述服务端发送连接请求,以使所述服务端基于所述连接请求与客户端之间建立连接。
在另一个可选的实施例中,所述获取所述服务端的服务IP,可以包括:
将解析所述连接码得到的IP地址作为所述服务端的服务IP;和/或
将本机IP的主机地址替换为解析所述连接码得到的主机地址,并将替换后的IP地址作为所述服务端的服务IP;和/或
将本机IP的主机地址和低位网络地址替换为解析所述连接码得到的主机地址和低位网络地址,并将替换后的IP地址作为所述服务端的服务IP。
在本申请一示例性实施例中,提供一种计算机设备,包括存储器、处理器及存储在存储器上并可在处理器上运行的计算机程序,所述处理器执行所述程序时可以实现以下步骤:
根据服务端的服务IP和端口号进行编码生成连接码;
将生成的连接码显示在用户界面上,以使客户端解析用户输入的所述连接码获取所述服务IP和端口号;
在接收到所述客户端基于所述服务IP和端口号发送的连接请求时,基于所述连接请求与所述客户端建立连接。
在一个可选的实施例中,所述处理器执行根据服务端的服务IP和端口号进行编码生成连接码时,可以实现以下步骤:
将完整的所述服务IP和端口号进行编码生成连接码;和/或
将所述服务IP的主机地址和端口号进行编码生成连接码;和/或
将所述服务IP的主机地址、低位网络地址和端口号进行编码生成连接码。
在另一个可选的实施例中,所述处理器执行所述程序时还可以实现以下步骤:
在生成所述连接码时,在所述连接码中扩展多位比特位作为第一安全码;
在接收到客户端发送的连接请求时,将所述第一安全码与所述连接请求中的第二安全码进行比较;
如果所述第一安全码与所述第二安全码相同,则基于所述连接请求与所述客户端建立连接。
在另一个可选的实施例中,所述处理器执行所述程序时可以实现以下步骤:
获取用户输入的服务端的连接码;其中,所述连接码由所述服务端根据所述服务端的服务IP和端口号进行编码生成;
解析所述连接码,获取所述服务端的服务IP和端口号;
基于所述服务IP和端口号,向所述服务端发送连接请求,以使所述服务端基于所述连接请求与客户端之间建立连接。
在另一个可选的实施例中,所述处理器执行获取所述服务端的服务IP时,可以实现以下步骤:
将解析所述连接码得到的IP地址作为所述服务端的服务IP;和/或
将本机IP的主机地址替换为解析所述连接码得到的主机地址,并将替换后的IP地址作为所述服务端的服务IP;和/或
将本机IP的主机地址和低位网络地址替换为解析所述连接码得到的主机地址和低位网络地址,并将替换后的IP地址作为所述服务端的服务IP。
以上所述仅为本申请的较佳实施例而已,并不用以限制本申请,凡在本申请的精神和原则之内,所做的任何修改、等同替换、改进等,均应包含在本申请保护的范围之内。
Claims (10)
- 一种服务发现方法,其特征在于,所述方法应用于服务端,包括:根据服务端的服务IP和端口号进行编码生成连接码;将生成的连接码显示在用户界面上,以使客户端解析用户输入的所述连接码获取所述服务IP和端口号;在接收到所述客户端基于所述服务IP和端口号发送的连接请求时,基于所述连接请求与所述客户端建立连接。
- 根据权利要求1所述的方法,其特征在于,所述根据服务端的服务IP和端口号进行编码生成连接码,包括:将完整的所述服务IP和端口号进行编码生成连接码;和/或将所述服务IP的主机地址和端口号进行编码生成连接码;和/或将所述服务IP的主机地址、低位网络地址和端口号进行编码生成连接码。
- 根据权利要求1所述的方法,其特征在于,所述方法还包括:在生成所述连接码时,在所述连接码中扩展多位比特位作为第一安全码;在接收到客户端发送的连接请求时,将所述第一安全码与所述连接请求中的第二安全码进行比较;如果所述第一安全码与所述第二安全码相同,则基于所述连接请求与所述客户端建立连接。
- 一种服务发现方法,其特征在于,所述方法应用于客户端,包括:获取用户输入的服务端的连接码;其中,所述连接码由所述服务端根据所述服务端的服务IP和端口号进行编码生成;解析所述连接码,获取所述服务端的服务IP和端口号;基于所述服务IP和端口号,向所述服务端发送连接请求,以使所述服务端基于所述连接请求与客户端之间建立连接。
- 根据权利要求4所述的方法,其特征在于,所述获取所述服务端的服务IP,包括:将解析所述连接码得到的IP地址作为所述服务端的服务IP;和/或将本机IP的主机地址替换为解析所述连接码得到的主机地址,并将替换后的IP地址作为所述服务端的服务IP;和/或将本机IP的主机地址和低位网络地址替换为解析所述连接码得到的主机地址和低位网络地址,并将替换后的IP地址作为所述服务端的服务IP。
- 一种服务发现装置,其特征在于,所述装置应用于服务端,包括:生成单元,用于根据服务端的服务IP和端口号进行编码生成连接码;通知单元,用于将生成的连接码显示在用户界面上,以使客户端解析用户输入的所述连接码获取所述服务IP和端口号;建立单元,用于在接收到所述客户端基于所述服务IP和端口号发送的连接请求时,基于所述连接请求与所述客户端建立连接。
- 根据权利要求6所述的装置,其特征在于,所述装置还包括:扩展单元,用于在生成所述连接码时,在所述连接码中扩展多位比特位作为第一安全码;比较单元,用于在接收到客户端发送的连接请求时,将所述第一安全码与所述连接请求中的第二安全码进行比较;所述建立单元还用于当所述第一安全码与所述第二安全码相同时,基于所述连接请求与所述客户端建立连接。
- 一种服务发现装置,其特征在于,所述装置应用于客户端,包括:获取单元,用于获取用户输入的服务端的连接码;其中,所述连接码由所述服务端根据所述服务端的服务IP和端口号进行编码生成;解析单元,用于解析所述连接码,获取所述服务端的服务IP和端口号;发送单元,用于基于所述服务IP和端口号,向服务端发送连接请求,以使所述服务端基于所述连接请求与客户端之间建立连接。
- 一种计算机可读存储介质,其上存储有计算机程序,其特征在于,所述程序被处理器执行时实现权利要求1至5任意一项所述方法的步骤。
- 一种计算机设备,包括存储器、处理器及存储在存储器上并可在处理器上运行的计算机程序,其特征在于,所述处理器执行所述权利要求1至5任意一项所述的方法。
Applications Claiming Priority (2)
| Application Number | Priority Date | Filing Date | Title |
|---|---|---|---|
| CN201710655640.X | 2017-08-03 | ||
| CN201710655640.XA CN107566453B (zh) | 2017-08-03 | 2017-08-03 | 服务发现方法、装置、计算机可读存储介质和计算机设备 |
Publications (1)
| Publication Number | Publication Date |
|---|---|
| WO2019024381A1 true WO2019024381A1 (zh) | 2019-02-07 |
Family
ID=60973968
Family Applications (1)
| Application Number | Title | Priority Date | Filing Date |
|---|---|---|---|
| PCT/CN2017/116084 Ceased WO2019024381A1 (zh) | 2017-08-03 | 2017-12-14 | 服务发现方法、装置、计算机可读存储介质和计算机设备 |
Country Status (2)
| Country | Link |
|---|---|
| CN (1) | CN107566453B (zh) |
| WO (1) | WO2019024381A1 (zh) |
Families Citing this family (11)
| Publication number | Priority date | Publication date | Assignee | Title |
|---|---|---|---|---|
| CN108848164B (zh) * | 2018-06-15 | 2022-02-25 | 广州视源电子科技股份有限公司 | 显示设备的连接方法、显示设备及系统 |
| CN108848162B (zh) * | 2018-06-15 | 2021-11-23 | 广州视源电子科技股份有限公司 | 显示设备的连接方法、显示设备及系统 |
| CN109088757B (zh) * | 2018-08-02 | 2021-11-16 | 广州视源电子科技股份有限公司 | 服务提供方法、装置和系统 |
| CN109246222A (zh) * | 2018-09-21 | 2019-01-18 | 郑州云海信息技术有限公司 | 服务请求处理方法、装置、系统及计算机可读存储介质 |
| CN110392124B (zh) * | 2019-06-11 | 2022-04-08 | 广州视源电子科技股份有限公司 | 电子设备的通讯码的生成方法、装置、系统以及电子设备 |
| CN111355820B (zh) * | 2019-06-27 | 2023-07-21 | 鸿合科技股份有限公司 | 一种数据传输方法、终端及电子设备 |
| CN111355821A (zh) * | 2019-06-27 | 2020-06-30 | 鸿合科技股份有限公司 | 一种连接码生成方法、设备、电子设备及存储介质 |
| CN111355558B (zh) * | 2019-06-27 | 2024-07-26 | 鸿合科技股份有限公司 | 一种提高连接码连接准确率的方法及相关设备 |
| CN111447213B (zh) * | 2020-03-24 | 2022-07-05 | 杭州海康威视数字技术股份有限公司 | 用于发现服务的验证码确定方法、装置及设备发现系统 |
| CN115412267A (zh) * | 2021-05-26 | 2022-11-29 | 广州视源电子科技股份有限公司 | 设备连接方法、装置及连接码生成方法 |
| CN114938361B (zh) * | 2022-05-30 | 2024-08-02 | 阿里云计算有限公司 | 媒体服务提供方法、系统、设备及存储介质 |
Citations (5)
| Publication number | Priority date | Publication date | Assignee | Title |
|---|---|---|---|---|
| US20070130346A1 (en) * | 2005-12-02 | 2007-06-07 | Xie Bo | Method for maintaining telnet session, telnet agency and computer network system |
| CN101155146A (zh) * | 2006-09-14 | 2008-04-02 | 株式会社理光 | 网络设备 |
| CN101192936A (zh) * | 2006-11-29 | 2008-06-04 | 阿里巴巴公司 | 一种建立数据访问连接的方法、系统及用户终端 |
| CN102882703A (zh) * | 2012-08-31 | 2013-01-16 | 赛尔网络有限公司 | 一种基于http分析的url自动分类分级的系统及方法 |
| CN107332912A (zh) * | 2017-07-03 | 2017-11-07 | 广州视源电子科技股份有限公司 | 服务发现方法、装置、系统及存储介质、计算机设备 |
Family Cites Families (2)
| Publication number | Priority date | Publication date | Assignee | Title |
|---|---|---|---|---|
| US8085708B2 (en) * | 2006-10-25 | 2011-12-27 | Sony Ericsson Mobile Communications Ab | Methods, systems, and devices for establishing a registrationless data communication connection between electronic devices |
| CN103391289A (zh) * | 2013-07-16 | 2013-11-13 | 中船重工(武汉)凌久高科有限公司 | 一种基于完成端口模型的多链路安全通信方法 |
-
2017
- 2017-08-03 CN CN201710655640.XA patent/CN107566453B/zh active Active
- 2017-12-14 WO PCT/CN2017/116084 patent/WO2019024381A1/zh not_active Ceased
Patent Citations (5)
| Publication number | Priority date | Publication date | Assignee | Title |
|---|---|---|---|---|
| US20070130346A1 (en) * | 2005-12-02 | 2007-06-07 | Xie Bo | Method for maintaining telnet session, telnet agency and computer network system |
| CN101155146A (zh) * | 2006-09-14 | 2008-04-02 | 株式会社理光 | 网络设备 |
| CN101192936A (zh) * | 2006-11-29 | 2008-06-04 | 阿里巴巴公司 | 一种建立数据访问连接的方法、系统及用户终端 |
| CN102882703A (zh) * | 2012-08-31 | 2013-01-16 | 赛尔网络有限公司 | 一种基于http分析的url自动分类分级的系统及方法 |
| CN107332912A (zh) * | 2017-07-03 | 2017-11-07 | 广州视源电子科技股份有限公司 | 服务发现方法、装置、系统及存储介质、计算机设备 |
Also Published As
| Publication number | Publication date |
|---|---|
| CN107566453A (zh) | 2018-01-09 |
| CN107566453B (zh) | 2021-02-09 |
Similar Documents
| Publication | Publication Date | Title |
|---|---|---|
| WO2019024381A1 (zh) | 服务发现方法、装置、计算机可读存储介质和计算机设备 | |
| JP5948647B2 (ja) | ネットワーク・アドレスを変換するシステムおよび方法 | |
| US9722806B2 (en) | Service discovery across different networks | |
| US9344339B2 (en) | Efficient service discovery for peer-to-peer networking devices | |
| JP6370985B2 (ja) | 端末によって接続を確立するための方法、装置、及びシステム | |
| CN107332912A (zh) | 服务发现方法、装置、系统及存储介质、计算机设备 | |
| CN101375566A (zh) | 利用动态dns的域名系统和动态dns服务器全局地址管理方法 | |
| CN104104926B (zh) | 一种通用即插即用的监控终端访问方法和装置 | |
| CN104969515B (zh) | 处理dns请求的方法和网关 | |
| US10904220B2 (en) | Provisioning using a generic configuration | |
| US12568062B2 (en) | Experience differentiation | |
| JP2015503876A (ja) | データ通信方法、装置、およびシステム | |
| CN114697879B (zh) | 蓝牙配对方法、电子设备、芯片和存储介质 | |
| CN102790813A (zh) | 基于IPv6网络的通信方法和系统以及终端设备 | |
| KR101396056B1 (ko) | 고유한 압축된 호 식별자 | |
| WO2019149006A1 (zh) | 获取、提供无线接入点接入信息的方法、设备以及介质 | |
| CN104869570A (zh) | 一种基于语言信道的说话终端确认方法 | |
| CN105052207B (zh) | 一种信息查询方法、设备及系统 | |
| WO2024001086A1 (zh) | 一种基于共享密钥进行数据通信的方法、装置、设备和介质 | |
| CN108769293B (zh) | 一种ip地址解析方法及相关装置 | |
| CN104168290B (zh) | 一种终端注册方法及注册服务器 | |
| US20120191798A1 (en) | Method and system for querying, monitoring and controlling a wireless sensor network using instant messaging system | |
| CN102694880B (zh) | 远程对象外网ip地址的获取方法、装置及系统 | |
| CN105577844B (zh) | 生成组播用户面地址的方法、核心网设备及终端 | |
| CN116980685A (zh) | 一种设备连接方法、装置、设备及存储介质 |
Legal Events
| Date | Code | Title | Description |
|---|---|---|---|
| 121 | Ep: the epo has been informed by wipo that ep was designated in this application |
Ref document number: 17919866 Country of ref document: EP Kind code of ref document: A1 |
|
| NENP | Non-entry into the national phase |
Ref country code: DE |
|
| 32PN | Ep: public notification in the ep bulletin as address of the adressee cannot be established |
Free format text: NOTING OF LOSS OF RIGHTS PURSUANT TO RULE 112(1) EPC , EPO FORM 1205A DATED 12.06.2020. |
|
| 122 | Ep: pct application non-entry in european phase |
Ref document number: 17919866 Country of ref document: EP Kind code of ref document: A1 |