Host is unresolved in LAN

白昼怎懂夜的黑 提交于 2019-12-02 19:24:10

问题


Im getting a IOExeption 'Host is unresolved' on HttpPost. The Endpoint in this case a a computer on my LAN with a webservice. (http://pc259:8080/test/service.asmx). Im using WIFI to my LAN. Does Android know to to resolved computernames?

StringEntity se = new StringEntity(xmlDataToSend);
se.setContentType("text/xml");
HttpPost httppost = new HttpPost(endPoint);     
httppost.setHeader("Content-Type","application/soap+xml");
httppost.setEntity(se);         
HttpClient httpclient = new DefaultHttpClient();
Log.i(TAG, " - Before execute");
httpResponse = (BasicHttpResponse) httpclient.execute(httppost);

回答1:


You can get Java to resolve NetBIOS names by using the JCIFS library. You can get it from http://jcifs.samba.org/. Add that to your project and then use code like this to convert a host name to an IP address.

import jcifs.netbios.NbtAddress;
...
NbtAddress nbtAddress = NbtAddress.getByName(hostname);
InetAddress address = nbtAddress.getInetAddress();
String ipAddress = address.getHostAddress();



回答2:


Most likely pc259 is not defined in you DNS server, but is a NetBios hostname (see http://en.wikipedia.org/wiki/NetBIOS#NetBIOS_name_vs_host_name).
I don't think Android can resolve these kind of hostnames - you'll need to add this computer to the DNS repository.



来源:https://stackoverflow.com/questions/3184463/host-is-unresolved-in-lan

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