[Haskell-cafe] Network.Socket Woes

Scott Bell sebell at gmail.com
Fri Mar 7 11:10:45 EST 2008

Hi all,

I'm trying to do some standard socket stuff using the
Network.Socket library. This example is a UDP server:

import Network.Socket

proto_udp :: ProtocolNumber
proto_udp = 17

port = 10162

main = do s <- socket AF_INET Datagram 17
          bindSocket s (SockAddrInet (PortNum port) iNADDR_ANY)
          putStrLn $ "Listening on port " ++ (show port) ++ "... "
          (msg, n, addr) <- recvFrom s 1024
          putStrLn $ "Received " ++ (show n) ++ " bytes from "
                       ++ (show addr) ++ ": "
          putStrLn (show msg)

Using the equivalent C program (socket, bind, recvfrom)
I'm able to successfully receive a 64 byte message from
my test program. The Haskell version, however, does not
return from recvFrom. I've also tried wrapping this in a
withSocketsDo, with no effect.

How can I proceed to debug/troubleshoot this program?


- Scott Bell

More information about the Haskell-Cafe mailing list