局域网的socket通讯与防火墙
昨天同事写了一个socket通讯程序。很简单,server端在7000端口监听,client端连接后,server向client发送一个字符串,client在收到该字符串后,再向server反馈一个消息。整个通讯过程结束。
Server和client在同一台机器时,整个通讯过程能够很顺利的完成。问题是,server和client在不同的机器时,client连接server失败。返回的错误码为[WSAETIMEDOUT:10060],错误消息为[
Connection refused. No connection could be made because the target computer actively refused it. This usually results from trying to connect to a service that is inactive on the foreign host—that is, one with no server application running.]
后来向网络管理人员咨询之后发现,原来是windows xp的防火墙在作怪。因为防火墙认为对其他端口的访问会影响本机的安全,所以该访问就被拒绝了。[本地连接] --> [属性] --> [详细设定] --> [设定]之后弹出设定对话框,有[设定],[例外],[详细设定]三个属性页。可以在例外中,将需要访问的7000端口添加进来,一切都ok了。
以上设定只需要在server端设定就可以了。
ファイアウォール