尽可能简单的跨平台Java UPNP打孔库
我需要一个具有简单 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 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
我建议您查看“使用 Java RMI 打孔,它可能会有所帮助。
I recommend you have a look at "Punching Holes with Java RMI, it might be helpful.
我环顾四周,发现最有前途的库是 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.