requestRouteToHost android

前端 未结 3 534
南方客
南方客 2021-01-28 02:05

Greetings everyone! I\'m getting rather fed up with android\'s ConnectivityManager class. I\'ve been trying for 5 hours to get the requestRouteToHost to work. I\'m running my co

3条回答
  •  梦谈多话
    2021-01-28 02:29

    The requestRouteToHost(lookupHost()) combination you are doing is very risky

    See your code:

    conn_man.requestRouteToHost(ConnectivityManager.TYPE_WIFI, lookupHost("localhost")))
    

    Here, you first made a host lookup, and next you are requesting a route to it. It will work fine only for static addresses (like localhost), where no real lookup is done. If you need a DNS lookup to resolve host address, it will fail easily. Generally, requestRouteToHost is handy for static addresses only.

提交回复
热议问题