[Haskell-cafe] UDP client/server

John Ky newhoggy at gmail.com
Fri Jan 12 00:26:36 EST 2007


Nevermind,

I just got the client to work:

echoClient :: IO ()
echoClient = withSocketsDo $ do
    sock <- socket AF_INET Datagram 0
    n <- sendTo sock "hi" (SockAddrInet echoPort 0x01000007f)
    return ()

Thanks everyone for your help.

-John

On 1/12/07, John Ky <newhoggy at gmail.com > wrote:Hi,

What's wrong with my UDP client?

echoClient :: IO ()
echoClient = withSocketsDo $ do
    putStrLn "[a]"
    sock <- socket AF_INET Datagram 0
    putStrLn "[b]"
    connect sock (SockAddrInet 9900 iNADDR_ANY)
    putStrLn "[c]"
    n <- send sock "hi"
    putStrLn "[d]"
    return ()

I get:

*Main> echoClient
[a]
[b]
*** Exception: connect: failed (Cannot assign requested address
(WSAEADDRNOTAVAI
L))

Thanks

-John
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://www.haskell.org/pipermail/haskell-cafe/attachments/20070112/2cd6ba63/attachment.htm


More information about the Haskell-Cafe mailing list