当前位置:   article > 正文

Receiving network data on Emulator_curl failure in receiving network data

curl failure in receiving network data
 

Your computer and Android device may talk to each other perfectly, but it does not work when you want to send data to you Emulator. In fact, each instance of the emulator runs behind a virtual router/firewall service that isolates it from your development machine's network interfaces and settings and from the internet. So you may get IP address like 10.0.2.15 on your Emulator.

In order to receive data on your Android Emulator regularly, open your command line console and type two commands.

 

Step 1: Connecting to the console of the target Emulator instance, specifying its console port number, as follows:

telnet localhost <console port number>

Console port number can be found on the title of the Emulator, and the console port number for the first emulator instance launched is 5554.

 

Step 2: Using the redir command to work with redirections.

redir add <protocol>:<host-port>:<guest-port>

Here, <protocol> is either tcp or udp, and <host-port> and <guest-port> sets the mapping between your own machine and the emulated system, respectively.

 

For example, the console port number of the Emulator instance is 5554, and the listen port for receiving UDP data in my application is 2011. Type the following two commands:

telnet localhost 5554

redir add udp:2011:2011

Now I can receive the data from IP address of my host (development) machine and the port 2011.

For details, please visit http://developer.android.com/guide/developing/devices/emulator.html

Note:

If your host machine is based on Window 7 system, you have to open the telnet client first. It can be done through Control Panel -> Programs and Features -> Turn Windows features on or off -> Telnet Client.

The Android Debug Bridge (ADB) tool provides port forwarding, an alternate way for you to set up network redirections. Visit http://developer.android.com/guide/developing/tools/adb.html#forwardports for details.

声明:本文内容由网友自发贡献,不代表【wpsshop博客】立场,版权归原作者所有,本站不承担相应法律责任。如您发现有侵权的内容,请联系我们。转载请注明出处:https://www.wpsshop.cn/w/Guff_9hys/article/detail/968643
推荐阅读
相关标签
  

闽ICP备14008679号