带有 C++ 的端口服务器/客户端应用程序

发布于 2024-10-30 08:15:48 字数 442 浏览 6 评论 0原文

如果我创建一个 C++ 服务器/客户端应用程序,我用于通信的端口是否需要在服务器和客户端计算机的路由器上打开

或者我可以采取什么其他方法?客户端计算机需要从服务器接收信息,但我无法打开任何端口,因为它位于学校网络上....

[编辑]

嗯,我的设置是在服务器上运行的 php 页面,当我按 hello 时说,服务器通过php建立ssh连接并向机器发送shell命令。该服务器在学校服务器上运行,我可以通过 ssh 访问该服务器并从那里运行我的所有内容。客户端计算机将是我的计算机,运行学校 WiFi,未连接到服务器。服务器将尝试与我的计算机的公共 IP 建立 ssh 连接,该计算机在学校 wifi 上运行(没有端口打开/可以 ssh 输出,但无法 ssh 输入)。您提到的这些方法是否可以实现这一点,特别是 connect.c 因为我无法从服务器运行 putty,而 connect.c 我可以从 php.ini 调用。

If I create a c++ server/client application, the port I used to communicate does it need to be open on the router of the server and client machine

Or what other approach could I take? the client computer needs to receive information from the server but I am not able to have any ports opened because it is on a school network....

[edit]

Hmm My setup is a php page running on a server say when I press hello, the server makes a ssh connection through php and sends shell commands to the machine. The server is running off of a school server which I do have ssh access to and run all my things from there. The client computer will be my pc running off of the school wifi which is not connected to the server. The server will try to make a ssh connection to the public ip of my computer running off of the school wifi(no ports open/can ssh out but no ssh in). Will these methods you mention make this possible, in particular the connect.c since I can't run putty off of the server, and the connect.c I could call from the php.

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

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

发布评论

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

评论(2

在梵高的星空下 2024-11-06 08:15:48

语言的选择在这里是非常无关紧要的。

任何路由器上都不需要“打开”端口,除非您的流量必须通过它。在同一网络(或子网)中的普通对等主机上几乎不会有任何防火墙策略,即使在学校也是如此。

从技术上讲,交换机可以阻止点对点流量(意味着不是发往传出网关的流量),但这并不常见。

当然,如果学校不允许大多数端口上的出站(WAN)流量,那么运气不好,他们绝对是对的:)

你可以看看

都很容易用谷歌搜索到

The choice of language is highly irrelevant here.

There don't need to be ports 'open' on any router, unless your traffic must pass through it. On normal peer hosts in the same network (or subnet) there would hardly be any firewall policy, not even in schools.

Technically it is possible for the switch to block peer-2-peer traffic (meaning traffic not destined to the outgoing gateway), but that is not very usual.

Of course, if the school doesn't allow outbound (WAN) traffic on most ports, tough luck, and they're absolutely right :)

You can look at

All very readily googled

┼── 2024-11-06 08:15:48

要建立 TCP/IP 连接,客户端只需访问服务器端口即可。连接是全双工的,因此数据可以从客户端流向服务器,反之亦然。

如果您的应用程序使用 UDP(一种无连接协议),则发生的情况在很大程度上取决于防火墙或路由器以及它是否为您的服务执行连接跟踪。

除非您提供有关您的服务以及客户端和服务器端网络设置的一些附加信息,否则我们无法提供更具体的信息。

To establish a TCP/IP connection, only the server port needs to be accessible by the client. The connection is full-duplex, therefore data can flow from the client to the server and vice-versa.

If you are using UDP for your application, which is a connection-less protocol, what happens depends heavily on the firewall or router and whether it performs connection tracking for your service or not.

Unless you provide some additional information on your service and the network setup on both the client and the server side, we cannot provide more concrete information.

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