# LAN communication

Base library 2.4.0 Provided the wx.startLocalServiceDiscovery Wait for a series mDNS API, which can be used to obtain information provided within the local network mDNS Service equipment IP。 wx.request/wx.connectSocket/wx.uploadFile/wx.downloadFile of url Parameters are allowed for ${IP}:${PORT}/${PATH} If and only if the IP With Cell Phones IP In the same network segment and not with the native IP The same (generally, the same LAN, such as connected to the same Wifi Below) when the request/The connection will succeed.

In this case, validation of the security domain is not performed and there is no requirement to use the https/Wss, you can also use http/ws。

wx.request({
  url: 'http://10.9.176.40:828'
  // Omitting other parameters
})

wx.connectSocket({
  url: 'ws://10.9.176.42:828'
  // Omitting other parameters
})

Base library 2.7.0 Started, provided the wx.createUDPSocket Interface is used to perform UDP Correspondence. Communication rules as above, only allow non-native computers under the same LAN IP。

# mDNS

At present, the Mini Program only supports mDNS Protocol to get the information of other devices in the LAN IP。iOS on mDNS API The implementation is based on the Bonjour,Android The above is based on Android System interface

Due to changes in operating system capabilities, iOS WeChat Client 7.0.18 The above version is not available. mDNS Related interface, the Android version is not affected

serviceType

initiate mDNS Service Search wx.startLocalServiceDiscovery The interface has serviceType Parameter that specifies the type of service to look for.

serviceType Format and specification, iOS [Bonjour Overview](https://developer.apple.com/library/archive/documentation/Cocoa/Conceptual/NetServices/Articles/Domainnames .html) in Bonjour Names for Existing Service Types Yes.

Bonjour serviceType.png

Android file This is also mentioned.

Android serviceType.png