Saturday, December 4, 2010

[android-developers] Re: connect my phone(Galaxy 2.1) to PC using socket communication, which IP and port number should i use?

On Dec 3, 12:43 am, Tantu <arungopa...@gmail.com> wrote:

> i want to connect my phone to PC using socket communication and my
> phone acts as a client in this communication. my code is working in
> emulator but not in phone.

This is not officially supported. That it works on the emulator is a
special case, due to the emulator being reverse-tethered to the PC for
its internet connectivity.

- By putting both the PC and the phone on the same wifi network you
may be able to do this.

- If the PC's service is accessible from the external internet you can
probably reach it from the phone's 3g connection

- If you have a version of froyo with USB tethering option, activating
this may as a side effect allow a client on the phone to connect to a
socket on the PC, though that's not the intent of this capability.

- If you connect the USB cable, enable USB debugging, and set up an
ADB port forward, you can connect from the PC to the phone, but not in
the other direction as you apparently want.

>  socket = new Socket("127.0.0.1", 5228);

Incidentally, that should not work on the emulator either, you need to
use the special alias for the PC's loopback interface. 127.0.0.1 is
the emulated device's own loopback.

--
You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to android-developers@googlegroups.com
To unsubscribe from this group, send email to
android-developers+unsubscribe@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en

No comments:

Post a Comment