ios - 从 ios 设备连接到 localhost

标签 ios http flutter localhost device

我的主机上正在运行 REST 服务。在 iOS 模拟器上运行时,我可以使用以下代码从我的 flutter 应用程序执行对此服务的 HTTP 请求:

final response = await http.get('http://localhost:8085/my/service');

但是,当我在 iOS 设备上运行该应用程序时,它会失败。我的设备通过 USB 连接。

Runner[574:66922] flutter: Error SocketException: OS Error: Connection refused, errno = 61, address = localhost, port = 49575

我需要配置什么才能从我的 iOS 设备连接到本地主机?

我已在 iTunes -> 摘要中禁用“通过 Wi-Fi 与此 iPad 同步”。

最佳答案

您可以使用当前的 IP,而不是 localhost

获取它在命令窗口中输入:ipconfig

Note that you must be on the same network

关于ios - 从 ios 设备连接到 localhost,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/58695851/

相关文章:

ios - 获取 PHAsset 的本地文件路径

java - Java 应用程序服务器如何决定在 HTTP Content-type header 中发送什么字符集?

api - 尝试查询 API,但 api 响应为空

html - 指出桌面版中的移动优化页面(html)

flutter - 在 flutter 中,在 initstate() 之前调用了dependOnInheritedElement()

ios - UITableViewCell 不能用一根手指点击,但可以用两根手指点击

ios - 如何在 uialertview Controller 的 uitext 字段中没有输入时禁用两个 uialertcontroller 按钮

ios - iPhone SDK_表格 View 里面的表格 View

Flutter 自动从 url 下载文件到下载目录

flutter - dart中等效的String.format java方法