vvis wrote:
>
> I want to send data(datastream, not files) from a PC to a real android 
> phone via USB. 
>
> I coded and set the phone to be a SERVER ,PC to be a CLIENT, and it 
> worded. 
>
> And, when I  set the Simulator to be a CLIENT,PC to be a SERVER , it 
> worded too. 
>
> BUT, when I  set the REAL Phone to be a CLIENT,PC to be a SERVER ,  it 
> did not word at all!!! 
>
> Code is like: 
> PC: 
> Runtime.getRuntime().exec("adb forward tcp:12580 tcp:10086"); 
> serverSocket = new ServerSocket(12580); 
>
> Android: 
> socket = new Socket(InetAddress.getByName("127.0.0.1"), 12580); 
>

This code fragment asks for a connection to port 12580 on the device 
itself.  So you are asking the Android device to connect to a socket on the 
same Android device.  Is that what you intended?

//While on the  Simulator use "10.0.2.2" it works!!! 


You don't show code or describe your configuration, so I'm not clear on 
what you mean by "works".  But generally you don't have a network 
connection between the device and your PC.  It takes something called 
"reverse tethering" via USB.  The emulator runs on the same network as its 
host, which is why you had no trouble there.

When Googling the terminology myself just now, I came across this 
badly-written but potentially useful little article:
http://www.codeproject.com/Articles/191930/Android-Usb-Port-Forwarding

There are problems with reverse tethering; tread carefully.

So you have two problems.  You're trying to connect the Android device to 
itself, and you have no network connection from the device to the PC.

-- 
Lew

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

Reply via email to