• <legend id='IlkQN'><style id='IlkQN'><dir id='IlkQN'><q id='IlkQN'></q></dir></style></legend>
  • <small id='IlkQN'></small><noframes id='IlkQN'>

  • <tfoot id='IlkQN'></tfoot>
      • <bdo id='IlkQN'></bdo><ul id='IlkQN'></ul>

        <i id='IlkQN'><tr id='IlkQN'><dt id='IlkQN'><q id='IlkQN'><span id='IlkQN'><b id='IlkQN'><form id='IlkQN'><ins id='IlkQN'></ins><ul id='IlkQN'></ul><sub id='IlkQN'></sub></form><legend id='IlkQN'></legend><bdo id='IlkQN'><pre id='IlkQN'><center id='IlkQN'></center></pre></bdo></b><th id='IlkQN'></th></span></q></dt></tr></i><div id='IlkQN'><tfoot id='IlkQN'></tfoot><dl id='IlkQN'><fieldset id='IlkQN'></fieldset></dl></div>
      1. 是否可以通过获取它们的 IP 地址来使用套接字连接两个 ios 设备?

        时间:2023-10-05
          <tfoot id='ugXZ5'></tfoot>

          <i id='ugXZ5'><tr id='ugXZ5'><dt id='ugXZ5'><q id='ugXZ5'><span id='ugXZ5'><b id='ugXZ5'><form id='ugXZ5'><ins id='ugXZ5'></ins><ul id='ugXZ5'></ul><sub id='ugXZ5'></sub></form><legend id='ugXZ5'></legend><bdo id='ugXZ5'><pre id='ugXZ5'><center id='ugXZ5'></center></pre></bdo></b><th id='ugXZ5'></th></span></q></dt></tr></i><div id='ugXZ5'><tfoot id='ugXZ5'></tfoot><dl id='ugXZ5'><fieldset id='ugXZ5'></fieldset></dl></div>

        • <legend id='ugXZ5'><style id='ugXZ5'><dir id='ugXZ5'><q id='ugXZ5'></q></dir></style></legend>
          • <bdo id='ugXZ5'></bdo><ul id='ugXZ5'></ul>

                  <tbody id='ugXZ5'></tbody>
              • <small id='ugXZ5'></small><noframes id='ugXZ5'>

                  本文介绍了是否可以通过获取它们的 IP 地址来使用套接字连接两个 ios 设备?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着跟版网的小编来一起学习吧!

                  问题描述

                  我想通过套接字连接多个设备,而不需要任何服务器实现.我将只使用它来获取将注册的设备的 IP 地址.

                  I want to connect multiple devices through socket without any server implementation.I will use that only for getting the IP addresses of the devices that will register.

                  推荐答案

                  点对点通信存在两个主要问题:发现和可达性.

                  There are two major problems to peer-to-peer communications: discovery, and reachability.

                  首先,您需要知道其他对等方的 IP 地址才能连接到它们.一旦你连接到对等点的网格,它们都可以互相更新网络状态,相互推荐更好的对等点,传递新的对等点加入和离开的通知等.但是你有设计和实施交易该信息的机制.更重要的是,您需要以某种方式快速启动事物,因为当一个新的对等点启动时,它只是在自己的网格中,并且它没有信息可以提供给自己.

                  First, you need to know the IP address of the other peers to connect to them. Once you're connected to a mesh of peers, they can all keep each other updated on the state of the network, suggesting better peers to each other, passing around notifications of new peers who've joined and left, etc. But you have to design and implement a mechanism for trading that information. More importantly, you need to jumpstart things in some way, because when a new peer starts up, it's in a mesh of just itself, and it has no information to give itself.

                  一种可能性是让少数著名的超级同行"(您运行的)始终保持连接,并将它们的地址烘焙到应用程序中.或者您可以使用介绍服务器"而不是对等服务器,提供大致相同的功能.或者您可以有一些外部交易地址的方式(最简单的是用户在网络论坛或 IRC 频道或亲自交易它们并手动输入它们),这可以在不同程度上实现自动化.还有一些捷径可以提供帮助——只要 LAN 上的一个对等点已经存在,Bonjour 就可以让其他对等点加入网格;GameCenter/GameKit 可用作自动化的外部交易网络;等等

                  One possibility is to have a handful of well-known "superpeers" (that you run) that are always connected, and bake their addresses into the app. Or you can have "introduction servers" instead of peers, serving much the same function. Or you can have some external way of trading addresses (the simplest is that users trade them on a web forum or an IRC channel or in person and type them in manually), which can be automated to various degrees. There are also shortcuts that can help—Bonjour can get other peers onto the mesh as long as one peer on the LAN is already there; GameCenter/GameKit can be used as an automated external trading network; etc.

                  一旦您解决了发现问题,您仍然会遇到可达性问题.大多数 iOS 设备通常没有可公开访问的 IP 地址;相反,它们位于进行网络地址转换的路由器之后,无论它们是家庭 WiFi 路由器还是蜂窝运营商的 3G 网络.这意味着您需要某种方式来进行 NAT 打孔,以使两部 iPhone 相互通话.知道每个设备的公共地址和内部地址的人可以安排他们建立彼此的连接.您可以让普通同行执行此操作(尽管这会使启动问题变得更大)或让您的超级同行/介绍服务器/等.去做吧.

                  Once you've solved the discovery problem, you still have the reachability problem. Most iOS devices usually don't have publicly-accessible IP addresses; instead, they're behind routers that do Network Address Translation, whether they be a home WiFi router or a cell carrier's 3G network. This means you need some way to do NAT Hole Punching to get two iPhones talking to each other. Somebody who knows both the public address and the internal address of each device can arrange for them to set up a connection to each other. You can have either normal peers do this (although that makes the jumpstart problem even bigger) or have your superpeers/introduction servers/etc. do it.

                  如果您想自己构建所有这些,您可能想查看其他实现.BitTorrent(包括跟踪器和 DHT)在从好奇的最终用户的对孩子撒谎"到详细的协议规范和开源实现的各个级别都得到了很好的理解和记录.然后看看其他一些 P2P 网络,因为 BitTorrent 并不完美,并且不会尝试做每个人都想出的所有事情.

                  If you want to build all of this yourself, you probably want to look at other implementations. BitTorrent (including trackers and DHT) is well-understood and documented at a continuum of levels ranging from "lies-to-children" for curious end users to detailed protocol specs and open source implementations. And then look at some other P2P networks, because BitTorrent is not perfect, and doesn't try to do everything that everyone's come up with.

                  这篇关于是否可以通过获取它们的 IP 地址来使用套接字连接两个 ios 设备?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!

                  上一篇:iOS 10.2 中的 MAC 地址 下一篇:如何使用 URLSessionStreamTask 和 URLSession 进行分块编码传输

                  相关文章

                1. <legend id='ntdnq'><style id='ntdnq'><dir id='ntdnq'><q id='ntdnq'></q></dir></style></legend>
                2. <tfoot id='ntdnq'></tfoot>

                      <i id='ntdnq'><tr id='ntdnq'><dt id='ntdnq'><q id='ntdnq'><span id='ntdnq'><b id='ntdnq'><form id='ntdnq'><ins id='ntdnq'></ins><ul id='ntdnq'></ul><sub id='ntdnq'></sub></form><legend id='ntdnq'></legend><bdo id='ntdnq'><pre id='ntdnq'><center id='ntdnq'></center></pre></bdo></b><th id='ntdnq'></th></span></q></dt></tr></i><div id='ntdnq'><tfoot id='ntdnq'></tfoot><dl id='ntdnq'><fieldset id='ntdnq'></fieldset></dl></div>

                        <bdo id='ntdnq'></bdo><ul id='ntdnq'></ul>

                      <small id='ntdnq'></small><noframes id='ntdnq'>