做了一个小程序在本机上可以,在其他机器上却发送不了数据。ping也能ping得通。
当时搞得我头痛得一匹,甚至拿了一个最简单的服务器客户端对联都不行。就算是小白也不可能这样都不定吧?最后发现,没错,小白就是小白。老老实实踩坑才是最关键的。
命令行开放端口
netsh advfirewall firewall add rule name="OPENUDPPort" dir=in action=allow protocol=UDP localport= 8888
OPENUDPPort:名字,随便取
Protocol:传输类型
localport:端口号
同理命令行开发程序
netsh advfirewall firewall add rule name="My Application" dir=in action=allow program="E:\Wireshark\Wireshark.exe" enable=yes
name:名字随便取
program:路径
删除开放的端口/程序规则
netsh advfirewall firewall delete rule name="OPENUDPPort" dir=in protocol=UDP localport=8888
netsh advfirewall firewall delete rule name="My Application" dir=in program="E:\Wireshark\Wireshark.exe
将add换成delete,去掉action和enable参数
在qt下呢。就是使用qprocess,但还是需要管理员权限