今天在服务器上运行自己写的程序的时候发现在自己机器上和其它服务器上跑的好好的代码竟然出错,其信息为“Bad protocol 'tcp'”,这可是头一次遇见这个问题,因为我使用的是PERL的WEBSERVICE服务器,需要远程调用其它网站的信息,所以我以为是防火墙没设置好,但从服务器上访问我需要的那个网站的时候却是没有问题的,也就是网络上应该是没问题的,没办法,先baidu了一把,结果在很快就找到了一个信息
Common problems If a grabber won't fetch web pages, it could be because of the 'protocols file' in Windows. If you do install perl, you can test with perl -MLWP::Simple -e "LWP::Simple::getprint 'http://www.google.com/'" If this says "Bad protocol 'tcp'" then probably the file C:\windows\system32\drivers\etc\protocol is bad or missing. Its contents should normally look like# Copyright (c) 1993-1999 Microsoft Corp.
#
# This file contains the Internet protocols as defined by RFC 1700
# (Assigned Numbers).
#
# Format:
#
# [aliases...]
ip 0 IP # Internet protocol
icmp 1 ICMP # Internet control message protocol
ggp 3 GGP # Gateway-gateway protocol
tcp 6 TCP # Transmission control protocol
egp 8 EGP # Exterior gateway protocol
pup 12 PUP # PARC universal packet protocol
udp 17 UDP # User datagram protocol
hmp 20 HMP # Host monitoring protocol
xns-idp 22 XNS-IDP # Xerox NS IDP
rdp 27 RDP # "reliable datagram" protocol
rvd 66 RVD # MIT remote virtual disk
You can try to create the file manually, or perhaps try the command:
netsh int ip reset "c:\log.txt"
or try to uninstall and reinstall TCP/IP from Control Panel.
大概意思就是C:\windows\system32\drivers\etc\protocol 这个文件可能有问题。想起前段时间配置服务器,对安全权限进行了些限制,于是立刻找到protocol这个文件,查看安全属性,发现有个系统账户和管理账户,还有个系统管理账户对其有访问使用权限,于是立刻加上了user用户,在运行程序,成功通过。
留写次文,以做备用。