[Haskell-cafe] UDP

Andrew Coppin andrewcoppin at btinternet.com
Sun Jan 25 11:22:41 EST 2009

I'm trying to write a simple program that involves UDP. I was hoping 
something like this would work:

module Main where

import Network.Socket

main = withSocketsDo main2

main2 = do
  s <- socket AF_INET Datagram defaultProtocol
  putStrLn "Waiting..."
  x <- recv s 100
  putStrLn x

Unfortunately, that doesn't work at all. It immediately throws an 
exception ("unknown error"). But then, the whole module seems to be 
completely undocumented. I managed to find a tiny amount of info online 
about the underlying C API, but I still don't get how the Haskell 
interface is supposed to be used. Any hints?

More information about the Haskell-Cafe mailing list