我们如何更改Android模拟器的IP

时间:2011-08-18 13:39:15

标签: android

我试图与2台PC模拟器进行通信。但在那之后我发现,两个模拟器都有相同的IP。如何区分哪个IP适用于哪个仿真器?有没有办法设置不同的IP?

1 个答案:

答案 0 :(得分:2)

请参阅Android开发者页面上的interconnecting emulator instances

简而言之:

To allow one emulator instance to communicate with another, you must set up the necessary network redirections as illustrated below.

Assume that your environment is

    A is you development machine
    B is your first emulator instance, running on A
    C is your second emulator instance, running on A too

and you want to run a server on B, to which C will connect, here is how you could set it up:

    Set up the server on B, listening to 10.0.2.15:<serverPort>
    On B's console, set up a redirection from A:localhost:<localPort> to B:10.0.2.15:<serverPort>
    On C, have the client connect to 10.0.2.2:<localPort>

For example, if you wanted to run an HTTP server, you can select <serverPort> as 80 and <localPort> as 8080:

    B listens on 10.0.2.15:80
    On B's console, issue redir add tcp:8080:80
    C connects to 10.0.2.2:8080