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.
精彩评论