如何将套接字连接到托管服务器的Genymotion设备? [英] How to connect a socket to Genymotion device that is hosting a server?

查看:207
本文介绍了如何将套接字连接到托管服务器的Genymotion设备?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我目前正在尝试从我的客户端(iOS模拟器)到我的主机(Genymotion模拟器)建立套接字连接。我很难找到正确的IP地址,并为VirtualBox配置正确的设置,使其工作。

I am currently trying to make a socket connection from my client (iOS simulator) to my host (Genymotion simulator). I am having a hard time finding the correct IP address and configuring the right settings for VirtualBox to get this to work.

如何找到正确的IP地址和端口当我在Genymotion服务器上托管服务器时,iOS连接到?

How can I find the proper IP address and port for iOS to connect to when I host the server on the Genymotion server?

推荐答案

默认情况下,Genymotion设备使用NAT连接互联网。这意味着它们在您的本地网络中不可见。您可以将此连接更改为桥接连接。这种类型的连接将允许您的本地DHCP给出Genymotion设备的IP,然后您就可以从本地网络上的任何地方访问它。

By default Genymotion devices use a NAT connection to connect to internet. It means they are not visible from your local network. You can change this connection to a Bridged connection. This type of connection will let your local DHCP gives the Genymotion device’s IP, then you will be able to reach it from everywhere on your local network.

要解决这个问题,请打开VirtualBox应用程序,选择要设置的设备,打开设置>网络选项卡>适配器2>附加到:桥接适配器而不是NAT。

To fix this, open VirtualBox app, choose the device you want to setup, open the settings > Network tab > Adapter 2 > Attached to: "Bridged Adaptor" instead of "NAT".

您需要获取设备的本地IP。你可以运行这个命令:

Then you need to get the local IP of the device. You can get it by running this command:

adb shell "ifconfig | awk '/inet addr/{print substr(\$2,6)}' | awk 'NR==2'"

我们正致力于让这项功能在未来变得更轻松。我会在发布后更新帖子。

We are working on making this really easier in the future. I'll update the post when this will be released.

这篇关于如何将套接字连接到托管服务器的Genymotion设备?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆