Sun, 3 Mar 2002 09:30:31 +0000 (GMT)
On Sun, 3 Mar 2002 [email protected] wrote:
> 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?
> module Main(main) where
> import BSD
import Socket (withSocketsDo)
> main =
> do protocolEntry <- getProtocolByName "TCP"
> 2) Even if this is a valid error why doesn't the function tell me so that I
> can handle it rather than terminating?
It is a valid error. It is raising an exception which you can catch if you
import IO (catch, isDoesNotExistError)
catch (do protocolEntry <- getProtocolByName "TCP"
putStrLn ("Protocol name:" ++ (protoName protocolEntry)))
(\e -> if isDoesNotExistError e then
putStrLn "Error" else