java网络编程

发布于 2024-10-09 03:22:50 字数 241 浏览 0 评论 0原文

我用java编写了一个简单的网络程序,使用套接字。程序有一个客户端和一个服务器。

当用户在客户端输入一个单词时,服务器只需将该单词返回给客户端即可。

在服务器端,我使用 Serversocket 并将其绑定到端口 4444。为什么防火墙不阻止我的服务器 PC 上的此连接?

我问这个问题是因为之前我使用 corba 技术编写了这个程序,而我的服务器 PC 上的防火墙阻止了与此端口的连接;当我禁用防火墙时,程序运行良好。

I have written a simple network program on java using sockets. Program has a client and a server.

When user types a word on client side, server simply return this word to client.

On server side I use Serversocket and bind it to port 4444. Why does not firewall block this connection on my server PC?

I ask this question because earlier I wrote this program using corba technology, and firewall on my server PC was blocking the connection to this port; when I disabled the firewall the program worked fine.

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

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

发布评论

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

评论(2

千纸鹤带着心事 2024-10-16 03:22:50

我的第一个猜测是您的防火墙仅阻止众所周知和/或众所周知和已注册的端口。
查看这篇维基百科文章。要测试这一点,请将您的程序绑定到众所周知的端口和/或您的环境中未使用的已注册端口。

My first guess is that your firewall is only blocking well known and/or well known and registered ports.
Check out this wikipedia article. To test this, have your program bind to a well known port and / or a registered port that is not in use in your environment.

橙幽之幻 2024-10-16 03:22:50

也许您的防火墙不会阻止服务器套接字的打开,而只会阻止与它们的连接?在这种情况下,您将能够通过“localhost”连接到套接字,但不能连接到外部 IP(这意味着本地网络上的 IP,而不是路由器上的 IP)。

Maybe your firewall doesn't block the opening of server sockets, but only the connections to them? In this case you would be able to connect to the socket over "localhost", but not on your external IP (which means the IP on your local network, not the one at your router).

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