iOS - 是否可以通过localhost在应用程序之间进行通信? [英] iOS - Is it possible to communicate between apps via localhost?

查看:126
本文介绍了iOS - 是否可以通过localhost在应用程序之间进行通信?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

考虑这种假设情况:

鲍勃和夏娃的应用程序安装在同一部iPhone上。 Bob的应用程序正在运行并绑定到localhost:8080以从其自己的 UIWebView 中侦听AJAX调用。 Eve的应用程序在后台运行并试图通过向localhost:8080进行AJAX调用来干扰Bob的应用程序。

Bob and Eve's apps are installed on the same iPhone. Bob's app is running and binds to localhost:8080 to listen for AJAX calls from its own UIWebView. Eve's app runs in the background and tries to interfere with Bob's app by making AJAX calls to localhost:8080.

两个问题:


  1. 假设Eve的应用程序知道Bob的AJAX API,她的调用会成功吗? (即本地主机上的iOS沙箱流量是什么?)

  1. Assuming Eve's app knows Bob's AJAX API, will her calls be successful? (i.e. does iOS sandbox traffic on localhost?)

Eve的应用程序是否有可能嗅到Bob的应用程序正在生成的流量?

Is it possible for Eve's app to sniff the traffic Bob's app is generating?


推荐答案


  1. 如果Bob的应用程序正在运行,是的,Eve的应用程序可以连接到它。

有两种可能的方法可以实现这一点。由于Eve的应用程序在后台运行,因此Bob的应用程序位于前台,Eve的应用程序在后台连接到它。或者,Bob的应用程序在后台运行,Eve的应用程序在前台连接到它。

There are 2 possible ways to have this happen. Either Bob's app is in the foreground, and Eve's app connect to it in the background, given that Eve's app is running in background. Or, Bob's app is running in the background, and Eve's app connect to it in foreground.

默认情况下,iOS会在后台暂停应用程序。如果应用程序使用后台执行,并继续在后台运行,它可以像往常一样访问网络。

By default the iOS suspend apps in background. If the app make use of background execution, and continue to run in the background, it can access the network as usual.

您可能希望在Apple的关于网络和多任务的技术说明

You may want to read "Beyond The Basics" in Apple's technical notes on Networking and Multitasking


  1. 嗅探流量需要root访问权限,除非Eve的应用程序是越狱应用程序,否则无法完成。

在BSD部分中包括Mac OS X)文章 Wireshark CapturePrivileges ,它说明在BSD系统上我们需要有权访问BPF设备来捕获数据包(读取:嗅探网络流量)。只有root(或任何超级用户)才能访问BPF设备,或授予任何其他用户访问它们的权限。

In the section "BSD (including Mac OS X)" of the article Wireshark CapturePrivileges, it state that on BSD systems we need to have permission to access BPF devices to capture packets (read: sniff network traffic). Only root (or any superuser) can access the BPF devices, or grant permission to any other user to access them.

这篇关于iOS - 是否可以通过localhost在应用程序之间进行通信?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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