MonoTouch, test if remote device is found on local network

给你一囗甜甜゛ 提交于 2019-12-13 05:58:30

问题


I am using MonoTouch to develop an app which will connect to remote devices on a network. These devices have data which can be access through http queries.

If I provide a valid IP address to a controller the app works perfectly, however it hangs for a long time if the controller is not on the network. For this reason I thought it would be good to use the Reachability.cs class which can be found here:

https://github.com/xamarin/monotouch-samples/blob/master/ReachabilitySample/reachability.cs

Instead of using google.com as the host, I am using the IP address of the controller. I have read that there is a bug with this class which causes it to not like having "http" at the beginning of the URL. Having now tried numerous things to get this working I am out of ideas.

Do anyone have any suggestions? Perhaps I am reinventing the wheel here.


回答1:


Having now tried numerous things to get this working I am out of ideas.

From your question it's not clear what issue you're having with the Reachability class. Maybe you could edit it and add more details ? e.g. what you tried so far, how it reacts like: never works, throws/crash, inconsistent results ...

Do anyone have any suggestions?

If your main issue is blocking the UI of your application then you could (and should anyway) do your connection and data transfer asynchronously (or a separate thread) and once completed update your UI (from the main thread).

E.g. using WebClient.DownloadDataAsync



来源:https://stackoverflow.com/questions/11829960/monotouch-test-if-remote-device-is-found-on-local-network

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!