主机是无法解析局域网 [英] Host is unresolved in LAN

查看:230
本文介绍了主机是无法解析局域网的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

即时得到一个IOExeption主机是未解决的HttpPost。端点在这种情况下AA计算机上我的局域网与web服务。上(http:// pc259:8080 /测试/ service.asmx)。即时通讯使用WIFI,以我的局域网。难道Android的知道,以解决computernames?

  StringEntity SE =新StringEntity(xmlDataToSend);
se.setContentType(为text / xml);
HttpPost httppost =新HttpPost(终点);
httppost.setHeader(内容类型,应用程序/肥皂+ XML);
httppost.setEntity(SE);
HttpClient的HttpClient的=新DefaultHttpClient();
Log.i(TAG - 在执行);
HTT presponse =(BasicHtt presponse)httpclient.execute(httppost);
 

解决方案

您可以获取Java使用JCIFS库来解析NetBIOS名称。您可以从 http://jcifs.samba.org/ 得到它。添加到您的项目,然后用code这样的主机名转换为IP地址。

 进口jcifs.netbios.NbtAddress;
...
NbtAddress nbtAddress = NbtAddress.getByName(主机名);
InetAddress类地址= nbtAddress.getInetAddress();
串ip地址= address.getHostAddress();
 

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);

解决方案

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();

这篇关于主机是无法解析局域网的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆