getProtocolByName
dominic.j.steinitz@britishairways.com
dominic.j.steinitz@britishairways.com
Sun, 3 Mar 2002 07:15:50 +0000
Here's my test program. TCP is a valid protocol. But I get the following
when I run it. I'm running under W98 by the way. I have two questions:
1) Why do I get an error?
2) Even if this is a valid error why doesn't the function tell me so that I
can handle it rather than terminating?
Dominic.
C:\Dom\haskell\ping>main
Fail: does not exist
Action: getProtocolByName
Reason: no such protocol entry
C:\Dom\haskell\ping>version
C:\Dom\haskell\ping>"c:\program files\glasgow haskell
compiler\ghc-5.02\bin\ghc"
--version
The Glorious Glasgow Haskell Compilation System, version 5.02
module Main(main) where
import BSD
main =
do protocolEntry <- getProtocolByName "TCP"
{- The documentation gives no clue as to what
constitutes an error condition. Looking at the
C equivalent in
http://www.opengroup.org/onlinepubs/7908799/xns/endprotoent.html,
this gives a null pointer to the
data structure. Assume for now that the Haskell
equivalent returns a null protocol name. -}
if protoName protocolEntry == ""
then putStrLn "Error"
else putStrLn ("Protocol name: " ++ (protoName protocolEntry))