从 Java 服务器到多个 C++ 的高效文件传输客户?

发布于 2024-08-09 14:43:02 字数 408 浏览 9 评论 0原文

我需要通过 Internet 将文件从 Java 服务器快速传输到 C++ 客户端,其中通常有许多客户端需要相同的文件。我正在研究Java中的transferTo(),这听起来像是一个经过适当优化的发送文件的函数。然而,我不确定当我使用transferTo()时如何最好地在C++中接收它(即它是否只是原始数据传输,如何确定文件何时在客户端结束,等等)。我需要它在 Windows 和 Linux 上都能工作。另外,除了 TransferTo() 之外,是否还有其他方法可以提高效率,特别是利用许多客户端通常需要相同文件的事实?我不知道如何说多播等。此外,我使用应用程序级安全性而不是 VPN,并且在 Java 服务器上使用 AES 加密并使用 MAC 数字签名,所以我也在寻找跨平台库推荐,以最小的痛苦处理 C++ 端的加密。 我非常精通 C++,但以前没有网络编程经验,所以请考虑任何建议。 谢谢。

I need to transfer files fast over the Internet from a Java server to C++ clients, where often many clients would need the same files. I was looking at say transferTo() in Java which sounds like it would be a decently optimized function to send files. However, I'm not sure when I use transferTo() how to best receive that in C++ (i.e. is it just a raw data transfer, how do I determine when the file is over on the client side, etc.). I need this to work on both Windows and Linux. Also, other than transferTo(), would there be some way to be more efficient, especially by taking advantage of the fact that many clients will usually need the same files? I'm not sure how to do say multicast etc. Also, I'm using application-level security rather than a VPN, and on the Java server, encrypting with AES and using MAC digital signing, so I'm also looking for a cross-platform library recommendation to deal with the crypto on the C++ side with minimal pain.
I'm very proficient in C++ but have no previous experience with network programming, so please consider than in any suggestions.
Thanks.

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

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

发布评论

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

评论(4

空城之時有危險 2024-08-16 14:43:02

嵌入式网络服务器? http 传输对您来说足够高效吗?

我记得见过的最简单的嵌入式 Java Web 服务器是 http://acme.com/java /software/Acme.Serve.Serve.html。我们在生产中使用嵌入式 Jetty 6,但这需要更多的努力。

如果您的客户一开始不知道在哪里可以找到您的网络服务器,请考虑使用 Zeroconf。 http://jmdns.sourceforge.net/

An embedded webserver? http-transfers are efficient enough for you?

The simplest embeddable Java webserver I remember seeing is http://acme.com/java/software/Acme.Serve.Serve.html. We use embedded Jetty 6 in production at work, but that takes more elbow grease.

If your clients doesn't know where to find your webserver in the first place, consider announcing using Zeroconf. http://jmdns.sourceforge.net/

江湖彼岸 2024-08-16 14:43:02

出于可扩展性的原因,Thorbjørns 使用 http 的建议似乎是一个非常好的主意,因为它可以让您轻松设置用于缓存的 http 代理、使用标准负载平衡工具等等。

如果您想要传输的不仅仅是一大块数据,您可能想看看谷歌的协议缓冲区。它们允许在 java 和 c++ 端进行非常简单和快速的编码/解码。

For scalability reasons, Thorbjørns suggestion of using http seems like a very good idea as it would allow you to easily set up http proxies for caching, use standard load balancing tools and so forth.

If you are looking to transfer more than just a blob of data, you might want to have a look at googles protocol buffers. They allow for very easy and fast encoding/decoding on the java and c++ end.

眼泪都笑了 2024-08-16 14:43:02

考虑对文件进行分块并通过 UDP 数据报发送。 C++ 可以在收到它时重新编译。您是否考虑过实施/嵌入现有的 P2P 协议实施?

Consider chunking the file and sending via UDP datagram. C++ can re-compile as it receives it. Have you considered implementing/embedding an existing P2P protocol implementation?

北音执念 2024-08-16 14:43:02

如果您需要向许多客户端进行有效传输,那么您的瓶颈就是服务器。

为此,请查看 Bit-Torrent 协议,因为它在客户端之间分配传输。

If you need effecient transfer to many clients then your bottleneck is the server.

For this please look at the bit-torrent protocol as it distributes the transfer between the clients.

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