Socket library ghc 5.02.1

Sigbjorn Finne sof@galois.com
Tue, 27 Nov 2001 06:34:34 -0800


"Sven Eric Panitz" <sep@softwareag.com> writes:
> 
...
> 
> I tried the following little test, which stays away from
> above functions:
> 
> > module Main where
> > 
> > import BSD
> > import SocketPrim
> > import Socket (withSocketsDo)
> >
> > main =  
> >  Socket.withSocketsDo
> >   (do
> >     protNum <- getProtocolNumber "tcp"
> >     s <- socket AF_INET Stream protNum
> >     hostAddr <- inet_addr "157.189.164.68"
> >     let sAddr =  (SockAddrInet (toEnum 8080) hostAddr)
> >     connect s sAddr
> >     i <- sendTo  s "GET / HTTP/1.0\r\n\r\n" sAddr
> >     (str,l,imsAddr) <- recvFrom s 1000
> >     putStr str
> >   )
> 
> 
> But something I seem to be doing wrong.
> 
> During evaluation of 'recvFrom s 1000' I get the following
> error message (consistently for unix and windows):
> 
>   Fail: SocketPrim.hsc:241: Non-exhaustive patterns in case
> 

You're doing something slightly non-standard here, using recvfrom()
on a connected socket, but I understand why you're doing it (as you
don't have any other SocketPrim alternatives for sucking data off of a
connected socket). This shows up a bug/problem in the implementation
of 'recvFrom', I'm afraid.

Conclusion: you're hosed with ghc-5.02.1 and its socket libs under
Win32. Sorry.

--sigbjorn

btw, I've checked in a fix to 'recvFrom' and added wrappers for send()
and recv(), but that won't help you short-term.