首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > 移动开发 > Android >

关于android模拟器IP有关问题

2013-12-28 
关于android模拟器IP问题?最近学习android与pc通过socket互连?PC做服务器时,android模拟器用10.0.2.2去连P

关于android模拟器IP问题?
最近学习android与pc通过socket互连?
PC做服务器时,android模拟器用10.0.2.2去连PC连接成功。
用android模拟器做server端,PC要用什么ip连接才能成功呢?求教。。。。
[解决办法]
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: 

1.Set up the server on B, listening to 10.0.2.15:<serverPort>
2.On B's console, set up a redirection from A:localhost:<localPort> to B:10.0.2.15:<serverPort>
3.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

热点排行