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

Hi, I'm using ActivePerl 5.8.4.810 with Windows 2000. It seems that no networking (not even ping) works. I am logged on as Administrator. Here's a couple of examples.
>perl -e "use NET::Ping; $p = Net::Ping->new();" Can't get tcp protocol by name at -e line 1 >perl -e "use NET::POP3; $pop = Net::POP3->new('192.67.198.62'); $pop- +>login('me');" Can't call method "login" on an undefined value at -e line 1. >ping 192.67.198.62 Pinging 192.67.198.62 with 32 bytes of data: Reply from 192.67.198.62: bytes=32 time=80ms TTL=245 Reply from 192.67.198.62: bytes=32 time=60ms TTL=245 Reply from 192.67.198.62: bytes=32 time=130ms TTL=245 Reply from 192.67.198.62: bytes=32 time=60ms TTL=245 Ping statistics for 192.67.198.62: Packets: Sent = 4, Received = 4, Lost = 0 (0% loss), Approximate round trip times in milli-seconds: Minimum = 60ms, Maximum = 130ms, Average = 82ms
Can anyone help?

Regards, DaveLaw.

Replies are listed 'Best First'.
Re: Windows Networking
by gellyfish (Monsignor) on Aug 10, 2004 at 09:05 UTC

    Hmm, it would seem that the %WINDIR%\system32\drivers\etc\protocols file has gone south, you should be able to replace this with one from another machine (even the /etc/protocols from a UNix machine should do), you might want to compare the directory to one on another Windows machine as it is likely that other files there (HOSTS,NETWORKS and SERVICES) will be missing too. Try fixing this first before reinstalling Windows.

    /J\

Re: Windows Networking
by Corion (Patriarch) on Aug 10, 2004 at 08:36 UTC

    From what I know, your TCP/IP stack is hosed. Theoretically, reinstalling/reinitializing it by issuing

    netsh int ip reset resetlog.txt

    should work magic. tachyon tackled the same problem and found a solution, so maybe that will help you. Should that not work, you'll have to reinstall your OS.

    Update: Changed order of last sentences and added a link to tachyons solution to the problem instead of just the main thread.

      Considering the OS's ping command works correctly I recommend NOT re-installing your OS. I think gellyfish may be on the right track. Worst case scenario I think you would need to re-install ActiveState Perl, not Windows.
Re: Windows Networking
by meetraz (Hermit) on Aug 10, 2004 at 18:46 UTC
    If your "protocol" file under %systemroot%\system32\Drivers\etc looks okay, then maybe Windows is no longer looking in the right place.

    Open up this registry key:

    HKEY_LOCAL_MACHINE\System\CurrentControlSet\Services\Tcpip\Parameters

    And look for a value named "DatabasePath". It should bet set to:

    %SystemRoot%\System32\drivers\etc
    HTH..
      ok:now someones talking sense! Heres the story: some time ago a Trojan tried to hijack the hosts file & pointed DatabasePath somewhere else. We found the imposter hosts but not the registry change. After pointing DatabasePath to the right place, Perl is networking ok. Funny thing is: windows could live with this, presumably looking where it should, having found no imposter hosts. Thanks very much!
Re: Windows Networking
by DaveLaw (Initiate) on Aug 10, 2004 at 12:22 UTC
    I'm not sure that reinstalling anything or hacking around in the registry on an otherwise perfectly functioning system is the answer. I think the right approach would be fixing the getprotobyname function to work on windows.

      It's nothing to do with gethostbyname() not working on Windows, there IS an important file missing from your system - you will get the same behaviour on Unix:

      [root@orpheus jonathan]# perl -e 'use Net::Ping; $p = Net::Ping->new() +;' [root@orpheus jonathan]# mv /etc/protocols /etc/protocols.bak [root@orpheus jonathan]# perl -e 'use Net::Ping; $p = Net::Ping->new() +;' Can't get tcp protocol by name at -e line 1 [root@orpheus jonathan]#
      If you want to test this then create a file called 'protocols' int %WINDIR%\System32\Drivers\etc and put:
      tcp 6 TCP
      In it and try your code again.

      Something else has messed your system up and it is not Perl's fault

      /J\

        gellyfish, my network is working fine. Windows does not have a file called protocols in %WINDIR%\system32\drivers\etc\. There is one called protocol which hasn't been touched since 1999, is identical on the many systems we have here & 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