尽可能简单的跨平台Java UPNP打孔库

发布于 2024-09-27 07:00:32 字数 704 浏览 4 评论 0原文

我需要一个具有简单 API 的库。定义简单:对我来说完美的解决方案就像这里所描述的那样但在 Java 中添加了跨平台使用(对我来说跨平台是适用于 Win、Mac、Lin 的独立 desctop 应用程序).​​..那么我希望看到的 API 是什么样子的呢?就像我在 C# 中所做的那样:

using TCMPortMapper;

private void Form1_Load()
{
  PortMapper.SharedInstance.Start();
  PortMapping pm = new PortMapping(localPort, publicPort, 
         PortMappingTransportProtocol.TCP);
  PortMapper.SharedInstance.AddPortMapping(pm);
}
private void Form1_FormClosing()
{
  PortMapper.SharedInstance.StopBlocking();
}

我打算用它做什么?我想创建易于使用的 Google App Engine 免费计划分布式(类似云)文件服务器,该服务器通常基于我的应用程序用户计算机......也就是说,他们使用我的应用程序,他们拥有它=)

I need a library with simple API. Defining simple: perfect solution for me would be something like described here but addopted for crossplatform use in Java (crossplatform for me is stand alone desctop app for Win, Mac, Lin)... So how API I would like to see looks like? Like oneI have in C#:

using TCMPortMapper;

private void Form1_Load()
{
  PortMapper.SharedInstance.Start();
  PortMapping pm = new PortMapping(localPort, publicPort, 
         PortMappingTransportProtocol.TCP);
  PortMapper.SharedInstance.AddPortMapping(pm);
}
private void Form1_FormClosing()
{
  PortMapper.SharedInstance.StopBlocking();
}

What I plan to do with it? I want to create easy in use with Google App Engine free plan distributed (cloud like) file server that would be generaly based on my app users computers... so to say they use my app they houst it=)

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

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

发布评论

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

评论(2

豆芽 2024-10-04 07:00:32

我建议您查看“使用 Java RMI 打孔,它可能会有所帮助。

I recommend you have a look at "Punching Holes with Java RMI, it might be helpful.

三生殊途 2024-10-04 07:00:32

我环顾四周,发现最有前途的库是 miniupnp。有关如何执行此操作的官方规范称为 UPnP IGD,它非常复杂且难以阅读。

应该可以通过 Java 执行此操作,您需要网络功能以及足够的权限来发送和接收 UDP 数据包特殊端口。我进行了一次 Python 移植尝试,结果成功我的 LAN,你可以移植它(这是 miniupnp 的简化)。如果您还没有花时间学习Python,我强烈推荐它。

I looked around and the most promising library I found was miniupnp. The official specs on how to do this are called UPnP IGD, and it's painfully complicated and nasty to read.

It should be possible to do this from Java, you need network capabilities, and sufficient privileges to send and receive UDP packets on special ports. I made a Python porting attempt that worked on my LAN, you might port that (it's a simplification of miniupnp). If you haven't taken the time to learn Python, I highly recommend it.

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