简单的文件传输
我想用 C 创建一个应用程序,允许两个用户共享文件。我将发送文件的人称为服务器,将接收者称为客户端。有几个要求:
- 用户不需要身份验证,不需要“登录”。你可以说它们对于我的应用程序来说是未知的。
- 服务器选择要传输的文件,并返回一个简单的约 10 个字符的 ID 字符串/哈希,客户端可以使用它来检索文件。
- 相同的应用程序用于服务和接收。
- 我的应用程序不需要在远程服务器上运行专用软件,除非它是免费提供的(例如 BitTorrent 跟踪器)。
现在这听起来很像 BitTorrent,我正在认真考虑通过 BitTorrent 来实现这一点。我不知道我会怎么做。有没有好的种子创建/播种/下载库?
请通过以下任一方式回答这个问题:
- 为 BitTorrent/其他想法提出可行的替代方案。
- 发布良好的 C 语言库/片段/bittorrent 协议实现。
I want to create an application in C that allows two users to share a file. I'll call the person sending the file the server and the receiver the client. There are a few requirements:
- The users need no identification, no "login". You could say they are unknown for my application.
- The server selects a file for transfer and gets returned a simple ~10 character ID string/hash that the client can use to retrieve the file.
- The same application is used for both serving and receiving.
- My application must not need dedicated software running on a remote server, unless it's freely available (e.g. bittorrent trackers).
Now this sounds a lot like bittorrent and I am seriously thinking of doing this through bittorrent. I'm not sure how I would do this. Are there any good libraries for torrent creation / seeding / downloading?
Please answer this question by either:
- Posing a viable alternative for bittorrent / other ideas.
- Posting good libraries / snippets / implementations of the bittorrent protocol in C.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
这听起来确实像是最好用 BitTorrent 来完成的事情。您看过 libbt 吗?它没有很好的文档记录,但确实包含一个示例客户端,即 /src/ 中的 btget.c。
This does indeed sound like something best done with BitTorrent. Have you had a look at libbt? It's not very well documented but does include a sample client, which is btget.c in /src/.
我现在找到了这个库:rasterbar libtorrent。它是用 C++ 编写的,但我不介意(反正我也不太了解)。
如果其他人正在寻找与我相同的东西,请在此分享以供将来参考。
I have now found this library: rasterbar libtorrent. It's in C++ but I don't mind (I don't know either that well anyway).
Sharing here for future reference if other people are looking for the same thing as me.
另一种解决方案是通过 IRC 服务器(如 Freenode)发送文件。在使用 BitTorrent 打开端口时遇到问题后,我想出了这个解决方案。
And an other solution, send the file through an IRC server (like Freenode). I came up with this solution after I had trouble with opening ports with bittorrent.