Socket library ghc 5.02.1

Sigbjorn Finne sof@galconn.com
Mon, 26 Nov 2001 12:30:47 -0800


 "Sven Eric Panitz" <sep@softwareag.com> writes:
> 
> It seems that the Socket library does still not work
> with ghc 5.02.1.
> I tried the simple test:
> 
> > main =
> >     do
> >     d <- connectTo "localhost" (PortNumber 80)
> >     hPutStr d "GET / HTTP/1.0\n\n"
> >     hFlush d
> >     c <- hGetContents d
> >     putStr c
> 
> On Windows2000 I get the known error:
> 
> *** Exception: does not exist
> Action: getProtocolByName
> Reason: no such protocol entry
> 

(You, of course, need to wrap up that code with Socket.withSocketDo
to start up WinSock first).

FYI, in case you're planning on doing socket programming with GHC-5.02
on a Win32 platform, stay away from using the higher-level Socket module,
since its IO.Handle based view of sockets is just broken. Stick with the
lower-level SocketPrim interface instead.

Specifically, stay away from using the following:

   * Socket. connectTo
   * Socket.accept
   * Socket.sendTo
   * Socket. recvFrom
   * SocketPrim.socketToHandle

--sigbjorn