如何正确设置Android和iOS通过套接字进行通信的协议?

发布于 2025-01-17 07:54:54 字数 1326 浏览 0 评论 0原文

我们正在执行一个应用程序,其中Android和Mac彼此之间发送消息。到目前为止,我们设法处理了Android< - > Android,iOS< - > ios和macos< - > ios。我们使用Bonjour(Android中的NSD)进行发现。谈到Android< - > iOS/Mac,他们彼此发现了良好,但连接是有问题的。

在Android的末尾,我们使用Google的旧 nsdchat ,转换为kotlin并添加了coroutines以释放主线程。在Mac上,我们使用了。就像我说的那样,两个应用程序都可以在自己的操作系上工作。

使用Android< - > ios/macOS,在我们注册Android的服务后,Bonjour在Mac上识别出来。 Android也发现了Mac并解决了服务。连接后,Android表示,它连接了客户端套接字并设法发送消息,然后再从Mac的一边获取随机符号,尽管没有人会发送它,然后再关闭连接。另一方面,当您单击Android的“连接”时,Mac并未立即显示它们连接的任何迹象,但是当您从Android发送消息时,它会显示一些错误。 (所以他们之间有一些东西)

​/I.SSTATIC.NET/TELAU.PNG“ ALT =“在此处输入图像描述”>

我们在网络部分中没有受过验收,但是我们怀疑它与协议有关,正如它提到的那样, TLS。不知道我们是否必须对其进行一些额外的修改才能工作。是否像在Android中添加SSL套接字一样简单,并且可以解决该连接?几乎没有在线上没有示例,文学非常稀缺(所有这些都在没有跨功能的情况下被决定为自己的操作系统)。如果有人知道有什么问题/丢失的人,我可以扩展更多(添加我们的代码,进一步解释等)。

We're doing an app where Android and Mac send messages between each other. So far we managed to handle Android <-> Android, iOS <-> iOS and MacOS <-> iOS. We used Bonjour (NSD in Android) for discovery. When it comes to Android <-> iOS/Mac, they discover each other fine but the connecting is problematic.

On Android's end, to start we used Google's old nsdChat, converted to Kotlin and added coroutines to free up the main thread. On the Mac, we used Apple's Peer-to-Peer sample project of TicTacToe. Like I said, both apps work fine on their own OS.

Doing Android<->iOS/MacOS, after we register Android's service, Bonjour on Mac recognizes it. Android discovers the Mac too and resolves the service. After connecting, Android says it connected a client socket and manages to send a message before getting a random symbol back from Mac's side although no one sends it, before closing the connection. On the other side, when you click on Android's "Connect", Mac doesnt immediately shows any signs that they connected, but when you send the message from Android it shows some errors. (so there was something between them)

enter image description here

enter image description here

We're inexperienced in the Networking part, but we suspect it has something to do with the protocols, as it mentions SSL and TLS. Not sure if we have to do some extra modifications to it to work. Is it as simple as adding a SSL socket to Android and that that would fix the connection? There are practically no examples online, and literature is pretty scarce (all are mostly decidated to their own OS's, without cross functionality). I can expand more (add our code, explain further etc.) if there is someone who knows what's wrong/missing.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。
列表为空,暂无数据
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文