tachyon has asked for the wisdom of the Perl Monks concerning the following question:

Literally all of a sudden LWP has stopped working on my Win32 box. Everything networky except Perl is *still working* so I can browse, email, telnet, ssh etc. The error is:

500 Can't connect to api.google.com:80 (Bad protocol 'tcp') at google +line 5

There was a node Problem using Perl to access a webpage with the same error but there are no really useful answers (iburrel is the only one who almost fingers the problem). Why? If you read the IO::Socket::INET source you will see that this error actually means that the getprotobyname('tcp') call fails. You can test it directly like this:

# Linux $ perl -le '$,=" "; print getprotobyname("tcp")' tcp TCP 6 # Working Win32 system C:\>perl -le "$,=' '; print getprotobyname('tcp')" tcp TCP 6 C:\> # Broken Win32 system C:\>perl -le "$,=' '; print getprotobyname('tcp')" C:\> # Broken Win32 system Cygwin Administrator@JAMES ~ $ perl -le '$,=" "; print getprotobyname("tcp")' Administrator@JAMES ~ $

Now on Unix systems getprotobyname() is normally a lookup in the file /etc/protocols, where you find a entry for 'tcp'. I have no idea how this database is mantained under NT but mine has become corrupt.

Does anyone know where this info is maintined in Win32? As you can see it is related to the OS rather than Perl as even Cygwin is trying to get its data from here (and failing).

And no reinstalling Perl and Re-service packing the machine did not fix the issue. What changed between working and not working? Dunno - not much in the way of software that I can recall (a few hotfixes for last years bugs of course). Adaware is one new widget that does delete from the registry. It is a W2K box so there is no rollback. I will reinstall the OS if it comes to that but would prefer not to. I have googled and Super Searched, scanned the registry to no avail. Anyone got the juice on this?

cheers

tachyon

Replies are listed 'Best First'.
Re: bad protocol 'tcp' win32 error because getprotobyname is failing
by Mr. Muskrat (Canon) on Jul 15, 2004 at 05:10 UTC

      Thanks for the links. First I tried for the easy netsh way:

      C:\>netsh int ip reset reset.log The following command was not found: int ip reset reset.log. C:\> # bugger C:\>netsh netsh>int interface>ip interface ip>reset The following commands are available: Commands in this context: reset all - Resets configuration. interface ip>reset all The following command was not found: reset all. interface ip>do quality contol and testing The following command was not found: do quality contol and testing interface ip>^C # double bugger ;-)

      Oh, well so much for that. (I believe that is the approach on XP as you can't really delete TCP/IP) Next I tried the link you provided for W2K but reboots later it was still barfing. I found this M$ link which also suggests deleting a lot of registry values, so another 3 reboots later.....tada:

      C:\>perl -le "print getprotobyname('tcp')" tcpTCP6 C:\>HEAD perlmonks.org 200 OK Connection: close Date: Thu, 15 Jul 2004 06:37:48 GMT Server: Apache/1.3.27 Content-Type: text/html; charset=ISO-8859-1 Client-Date: Thu, 15 Jul 2004 06:39:06 GMT Client-Peer: 209.197.123.153:80 Client-Response-Num: 1 C:\>

      All is well in the world again. Thanks very much for your help, much appreciated.

      cheers

      tachyon

      I used to work in an isp faults department, and unfortunately this happens much more than you would think... I can remember many a strange (otherwise unexplaiable) networking error fixed by reinstalling or resetting tcp/ip. especially on Win XP.

      ++ to you for your sound advice.
Re: bad protocol 'tcp' win32 error because getprotobyname is failing
by BrowserUk (Patriarch) on Jul 15, 2004 at 05:25 UTC

    Before you go to the pain of re-installing tcp/ip, take a look in C:\WINDOWS\SYSTEM32\DRIVERS\ETC\PROTOCOL

    Mine looks like this:

    # Copyright (c) 1993-1999 Microsoft Corp. # # This file contains the Internet protocols as defined by RFC 1700 # (Assigned Numbers). # # Format: # # <protocol name> <assigned number> [aliases...] [#<comment>] 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

    Examine what is said, not who speaks.
    "Efficiency is intelligent laziness." -David Dunham
    "Think for yourself!" - Abigail
    "Memory, processor, disk in that order on the hardware side. Algorithm, algoritm, algorithm on the code side." - tachyon

      Thanks BrowserUk I ran filemon.exe and regmon.exe from Sysinternals which showed up this location (after I had posted) - the protocol file is still there on the broken box and looks just like the above. Regmon does not show the issue either when you diff the results of a working and broken system and filter for Winsock2.

      cheers

      tachyon

Re: bad protocol 'tcp' win32 error because getprotobyname is failing
by Anonymous Monk on Jul 15, 2004 at 16:27 UTC
    It should be under your system32 folder. On my system its C:\WINNT\system32\drivers\etc