As Bob said, the socket constructor just does InetAddress.getAllByName on
the destination name you provided.  If the name provided is a valid ip
string no dns lookup is performed and UnknownHostException shouldn't be
possible.

Could you perhaps have badly formated the string (used a comma instead of a
period) or used an out-of-range octet (>255)?

R


On Thu, Feb 7, 2013 at 7:08 AM, bob <[email protected]> wrote:

> This is the correct format:
>
> clientSocket = new Socket("192.168.0.100",PORT);
>
> I doubt you could get that exception if you were using that format.
>
>
>
>
> On Wednesday, February 6, 2013 9:54:04 PM UTC-6, Ananda Krishna wrote:
>>
>> hi Robert Greenwalt,
>> *I have given the ip address of the my pc which is the server for
>> testing the code.*
>> *Regards,*
>> *AnandaKrishna S*
>>
>> On Wednesday, February 6, 2013 7:22:16 PM UTC+5:30, Ananda Krishna wrote:
>>>
>>> Hi,
>>> I am running a server which sends data to the client i.e android device
>>> with the help of sockets via wifi .On client side i am getting the
>>> following exception.
>>> *Exception: java.net.unknownhostexception unable to resolve host .*
>>>
>>> *Code:*
>>> *
>>> *
>>> clientSocket = new Socket("MY_PC_IP(SERVER_IP)",**PORT);
>>> BufferedReader br = new BufferedReader(new InputStreamReader(**
>>> clientSocket.getInputStream())**);
>>> clientSocket.close();
>>>
>>> *Note : Both PC and the wifi connected android device is in the same
>>> network with proxy disabled for both PC and device.*
>>> *Any Suggestion in this regard would be appreciated.*
>>>
>>> Regards,
>>> AnandaKrishna S
>>>
>>>
>>>  --
> --
> You received this message because you are subscribed to the Google
> Groups "Android Developers" group.
> To post to this group, send email to [email protected]
> To unsubscribe from this group, send email to
> [email protected]
> For more options, visit this group at
> http://groups.google.com/group/android-developers?hl=en
> ---
> You received this message because you are subscribed to the Google Groups
> "Android Developers" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to [email protected].
> For more options, visit https://groups.google.com/groups/opt_out.
>
>
>

-- 
-- 
You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en
--- 
You received this message because you are subscribed to the Google Groups 
"Android Developers" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
For more options, visit https://groups.google.com/groups/opt_out.


Reply via email to