[Cloud Server] About UDP/TCP cross-platform network communication server unresponsive situation and solution

insert image description here

This article is only to record the problems and solutions I encountered in cross-platform udp communication

1. Problems arise

When performing udp network communication, I use Tencent Cloud Server as the server, and Windows as the client. When connecting, when I send a message from the client to the server, the server cannot receive the message (safety group already configured)
insert image description here

2. Cloud server Centos7 firewall open port

2.1 Check firewall status

sudo firewall-cmd --state

2.2 Turn on the firewall

systemctl start firewalld 

2.3 In the running state, add ports that need to be opened to the firewall

sudo firewall-cmd --permanent --zone=public --add-port=8080/udp
sudo firewall-cmd --permanent --zone=public --add-port=8080/tcp

2.4 Reload firewall configuration

sudo firewall-cmd --reload

2.5 Check whether the port is released

sudo firewall-cmd --permanent --zone=public --list-ports

When the above command is executed, the red box appears, which means the opening is successful
insert image description here

3. Cloud server firewall configuration open port

3.1 Enter the official website of Tencent Cloud Server, find the instance, and click Firewall

Please add a picture description

3.2 Add rules

Please add a picture description

3.3 Add port

Select the protocol type according to the needs, and fill in the port number you want to use for the port.
Please add a picture description
Run the program again to communicate normally! ! !

Thanks for reading, if it helps you, please like, comment + follow

Guess you like

Origin blog.csdn.net/m0_54469145/article/details/130655892