开发者

Problem with socket connection by using computer name?

I want to connect my cell-phone to PC by using socket connection.

But it's only successful when I use IP Address. I try to use Computer Name but it throws UnKnowHostException.开发者_开发知识库

mySocket = new Socket("192.168.1.100", 10000); //it's ok!

mySocket = new Socket("My_PC_NAME", 10000); //it throw UnKnowHostException !

My cell phone is using WIFI and its IP is : 192.168.1.99

Please help me, Thanks !


This is quite normal as your android device hasn't access to the DNS that assigns names to IP addresses. Since it isn't part of your PC network, you can't use computer names for the socket connection.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜