[Haskell-cafe] UDP client/server
John Ky
newhoggy at gmail.com
Thu Jan 11 19:54:54 EST 2007
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
On 1/12/07, Gregory Wright <gwright at comcast.net> wrote:
>
>
> Hi John,
>
> On Jan 11, 2007, at 10:35 AM, Gregory Wright wrote:
>
> >
> > Hi John,
> >
> > On Jan 11, 2007, at 1:58 AM, John Ky wrote:
> >
> >> Hello,
> >>
> >> Does anyone know where I can find a simple UDP client/server
> >> written in Haskell?
> >>
> >> Something along the lines of an echo server would do.
> >>
> >> Thanks
> >>
> >> -John
> >>
> >
> > Try:
> >
> >
>
> <snip>
>
> For testing, you need only use
>
> gregory-wrights-powerbook-g4-17> nc -ul -p 9900 127.0.0.1
>
> and whatever you type should be echoed. My original description
> of how to test:
> >
> > On my OS X/ppc 10.4.8 system, the above builds with ghc 6.6 and if
> > I open one
> > terminal with
> >
> > gregory-wrights-powerbook-g4-17> nc -u 127.0.0.1 9900
> >
> > and another with
> >
> > gregory-wrights-powerbook-g4-17> nc -ul -p 9900 127.0.0.1
> >
> > whatever I type into the first terminal appears on the second. You
> > may have to
> > consult your documentation for the options to your version of nc
> > (or netcat,
> > if you use that instead).
>
> is wrong. (It will copy from one terminal to the other when the
> daemon is not present.)
>
> Best,
> Greg
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://www.haskell.org/pipermail/haskell-cafe/attachments/20070112/6f61ec33/attachment.htm
More information about the Haskell-Cafe
mailing list