简体   繁体   English

在Windows OS上使用C ++检查特定的开放TCP端口

[英]Checking for a specific open TCP Port with C++ on Windows OS

I have a patching program for a game and before the button to open the game is able to be clicked I am wanting it to check that the server is actually online which has a static ip address and port that is used and never changes. 我有一个游戏的修补程序,在可以单击打开游戏的按钮之前,我希望它检查服务器是否真正在线,该服务器具有已使用且从未更改的静态IP地址和端口。 Right now it checks if there are any patches before the play button is activated but I want it to also check if the server is online. 现在,它会在激活播放按钮之前检查是否有任何补丁,但我希望它也检查服务器是否在线。

I've already been searching but perhaps I've not been using the right terminology. 我已经在搜索,但是也许我没有使用正确的术语。

Basically I don't need it to show any messages just check if the specific port is listening. 基本上,我不需要它来显示任何消息,只需检查特定端口是否正在侦听即可。

Have you just tried connecting? 您是否刚刚尝试连接?

TCP uses a three-way handshake: SYN, SYN-ACK, ACK . TCP使用三向握手: SYN, SYN-ACK, ACK You don't need to know the exact details, your OS will handle it if you connect. 您不需要知道确切的详细信息,如果您连接了操作系统,它将进行处理。 And if the other side does not have its port open, it won't reply with that SYN-ACK . 并且如果另一端未打开其端口,则不会用该SYN-ACK回复。 Your OS will time out and inform you that the other side ignored you. 您的操作系统将超时,并通知您另一方忽略了您。

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

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