> I've just had a couple of troubles with Socket and
> SocketPrim. Let's take
> the following program:
>
> ---------------------------------------------------------------
> module Main where
>
> import Socket hiding (recvFrom)
> import SocketPrim
>
> createSocket :: IO Socket
> createSocket = do
> sock <- socket AF_INET Datagram 0
> let addr = (SockAddrInet (mkPortNumber 2000)
> iNADDR_ANY) in do
> bindSocket sock addr
> return sock
>
> proc1 = connectTo "localhost" (PortNumber $ mkPortNumber 0) >>=
> hGetContents >>=
> print
>
> proc2 = do
> sock <- createSocket
> recvFrom sock 1000
>
> main = proc1 >> proc2
> ---------------------------------------------------------------
> IMO proc1 should throw some exception or report error. Yet it
> just outputs
> "".
> proc2 should hang on a socket until someone connects to it.
> Nevertheless,
> the program outputs:
>
> Fail: resource exhausted
> Action: recvFrom
> Reason: insufficient resources
>
> Maybe I'm doing sth wrong here?
As Sigbjorn points out, this is due to an incomplete implementation of
non-blocking socket operations in the socket library. I've fixed this now,
so if you build from CVS sources (in about 6 hours time when the mirror has
happened) your program should work as expected.
Cheers,
Simon