Objective-C Bonjour/TCP 堆栈

发布于 2024-07-29 23:53:14 字数 273 浏览 6 评论 0原文

我想知道是否有人知道组合 Objective-C Bonjour/TCP 堆栈,这会让我忘记管理套接字、广播服务等,而是让我只托管一个服务和/或获取现有服务的列表,连接到一个。 然后继续从服务器端向特定客户端发送消息或从客户端向服务器发送消息。

我认为任何收到的消息和/或发现的服务都将通过委托方法发送给我,其余的脏工作将由堆栈完成。

我意识到自己实现这并不是那么困难,而且我已经完成了其中一些,但使用成熟的框架会更有意义。

如果它与 iPhone 兼容,则额外加分。

I was wondering if anyone knows of a combined Objective-C Bonjour/TCP stack out there, that would allow me to forget about managing sockets, broadcasting services etc and instead let me just host a service and/or get a list of existing services and connect to one. Then just continue by sending messages either to specific clients from the server side or to the server from a client.

I presume any received messages and/or discovered services would be sent to me via delegate methods and doing the rest of the dirty work would be up to the stack.

I realize this is not all that tough to implement myself and I already have some of it done, but it would make a lot more sense to use a mature framework.

Extra points if it's iPhone compatible.

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

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

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(6

驱逐舰岛风号 2024-08-05 23:53:14

查看适用于 iPhone 的 Apple WiTap 示例应用程序。 您要求的许多结构已经存在。 您可以在 iPhone 开发中心 找到它。

Check out Apple's WiTap example app for iPhone. Many of the structures you are asking for already exist there. You can find it off of the iPhone Dev Center.

掐死时间 2024-08-05 23:53:14

听起来您正在寻找 iPhone SDK 中包含的 GameKit 框架。 GameKit 通过 GKSession 提供了您正在寻找的东西。 那里有很多文档,但是 官方Apple 指南 是一个很好的起点。

Sounds like you are looking for the GameKit Framework included in the iPhone SDK. GameKit, via GKSession, provides exactly what you are looking for. There is much documentation out there, but the official Apple guide is a great place to start.

若有似无的小暗淡 2024-08-05 23:53:14

我会说“你自己做”。

如果您认为问题中列出的要求不会改变,那么套接字服务器+网络服务的简单但经过充分测试的实现以及套接字+流的包装器就可以了 - 您甚至可能不需要“框架”本身。

我已经为教程实现了类似的东西,并且有到目前为止,已经在几个不同的项目中使用了它。 您正在查看 TCP 套接字服务器的大约 200 行代码,以及 Connection 类的大约 300 行代码(带有委托等)。

I'd say "do it yourself".

If you don't think that the requirements that you listed in the question will change, then a simple but well-tested implementation of a socket server+netservices and a wrapper for socket+streams will do just fine - you might not even need a "framework" per se.

I've implemented something similar for a tutorial and have been using it in a couple of different projects so far. You are looking at about 200 lines of code for a TCP socket server, and about 300 lines for a Connection class (with delegates and all that).

怎会甘心 2024-08-05 23:53:14

使用内置于两者中的 NSNetServices 怎么样? iPhone 和 OSX? 这完成了发布/订阅 Bonjour 服务的所有工作。

当然,如果您要发布服务,则需要一个套接字进行通信,并且根据您使用的协议,处理传入消息的方式(以及是否有响应等)意味着您必须对消息传递基础设施有一些先验知识。

如果您甚至懒得写这些内容,那么通过事实上的全包协议 HTTP 托管某些内容可能是前进的方向。 您可以在设备上托管您自己的迷你网络服务器,并让 HTTP 请求进行对话。 但服务的实现与服务的发现是正交的。

What about using the NSNetServices that's built in to both iPhone and OSX? That does all the work of publishing/subscribing Bonjour services.

Of course, if you're publishing a service, you need a socket to be communicated with, and depending on the protocol you're using, the way you handle incoming messages (and whether there are responses etc.) means that you have to have some knowledge a-priori of what that messaging infrastructure is.

If you can't even be bothered to write that, then hosting something over that de-facto all encompassing protocol, HTTP, is probably the way forward. You can just host your own mini webserver on the device and let HTTP requests do the talking. But the implementation of the service is orthogonal to the discovery of that service.

屌丝范 2024-08-05 23:53:14

ConnectionKit,它可以使通过 FTP、HTTP、SFTP 进行通信变得更加容易, WebDAV 和 Amazon S3。 它不直接支持 iPhone,因为 Cocoa 是它的依赖项之一,但我认为它是便携式的。 我不确定这对你的情况是否有任何用处,但我想我会把它扔在那里以防万一。

There is ConnectionKit, which can make things much easier for communication via FTP, HTTP, SFTP, WebDAV and Amazon S3. It doesn't support the iPhone directly, since Cocoa is one of its dependencies, but I imagine it's portable. I'm not sure if this would be of any use in your case, but thought I'd throw it out there just in case.

铃予 2024-08-05 23:53:14

使用 AsyncSocket 怎么样。 我个人没有使用过它,但它似乎是您的完美选择。

What about using AsyncSocket. I have not used it personally but it seems to be the perfect choice for you.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文