简体   繁体   English

路由器中没有转发端口的Java程序

[英]Java program without forward port in router

I made application with java using socket.我使用套接字用java制作了应用程序。 My computer is the server and my phone(android ) is the client.我的电脑是服务器,我的手机(android)是客户端。 Only what i trying to do is to forward String from phone to client PC.我唯一想做的是将字符串从手机转发到客户端 PC。

Everything works fine when i configure my router and open the port i using.当我配置路由器并打开我使用的端口时,一切正常。 i don't want every time when costumer will install my application will need to open port in the router.我不想每次客户安装我的应用程序时都需要在路由器中打开端口。

I thought about using remote server that will run my server code.我想过使用将运行我的服务器代码的远程服务器。 but i didn't find server that can do that .但我没有找到可以做到这一点的服务器。 i don't want to make my pc a server for all costumers.我不想让我的电脑成为所有客户的服务器。

How does all the chats companies do it without open port?没有开放端口,所有聊天公司都是如何做到的?

You must look into UPnP.您必须查看 UPnP。 This is what /most/ if not /all/ torrent clients use to allow foreign connections, without forwarding ports.这是 /most/ 如果不是 /all/ Torrent 客户端用于允许外部连接而不转发端口的内容。 How chat clients do it is a different scenario.聊天客户端如何做到这一点是一个不同的场景。 They use hacks such as firewall hole-punching using UDP (with an external server) http://www.h-online.com/security/features/How-Skype-Co-get-round-firewalls-747197.html see this link for details on UDP hole punching.他们使用诸如使用 UDP(带有外部服务器)的防火墙打孔之类的黑客攻击http://www.h-online.com/security/features/How-Skype-Co-get-round-firewalls-747197.html看到这个有关 UDP 打孔的详细信息的链接。

Also see this article http://www.codeproject.com/Articles/13285/Using-UPnP-for-Programmatic-Port-Forwardings-and-N for usage of UPnP.另请参阅这篇文章http://www.codeproject.com/Articles/13285/Using-UPnP-for-Programmatic-Port-Forwardings-and-N了解 UPnP 的使用。 But this is in C++, but I think you will understand.但这是在 C++ 中,但我想你会明白的。

EDIT: http://4thline.org/projects/cling/ I found this.编辑:http: //4thline.org/projects/cling/我发现了这个。 I think it can help you.我认为它可以帮助你。

You had to open port probably because of your routers firewall :).您必须打开端口可能是因为您的路由器防火墙:)。 If you already opened let us say port 9090 then every client app (android phone) will be able to connect to it :).如果您已经打开让我们说端口 9090,那么每个客户端应用程序(Android 手机)都可以连接到它:)。 Of course if somebody wants to install server on their own pc they would problably forward some ports and disable some firewalls.当然,如果有人想在自己的电脑上安装服务器,他们可能会转发一些端口并禁用一些防火墙。 If you want server with no special requriements lookup VPS'es.如果您想要没有特殊要求的服务器,请查找 VPS。 :) :)

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM