[Haskell-cafe] How to send a string somewhere via UDP

Jeffrey Brown jeffbrown.the at gmail.com
Mon Oct 20 23:19:21 UTC 2014


Chapter 27 of Real World Haskell
<http://book.realworldhaskell.org/read/sockets-and-syslog.html> explains a
way to send a message over UDP. From a folder containing the two files
"syslogclient.hs" and "SyslogTypes.hs" (which are attached to this email,
and also available here
<http://book.realworldhaskell.org/read/sockets-and-syslog.html>),
supposedly one can run these three commands from GHCI, to send the message
"This is my message" to localhost, port number 514:

:load syslogclient.hs
h <- openlog "localhost" "514" "testprog"
syslog h USER INFO "This is my message"

I have a Max/MSP patch that accepts UDP on localhost port number 9000. I
substitute 514 -> 9000 and run that, and I get nothing. I know the Max/MSP
"udpreceive" object is working, because from Python, using the aiosc
module, I can run

aiosc.send(('127.0.0.1', 9000), "This is a message from Python") )

and "This is a message from Python" reaches Max.

There is a UDP library
<http://hackage.haskell.org/package/network-conduit-0.6.1.1/docs/Data-Conduit-Network-UDP.html>
for
Haskell, which I presume could serve as an alternative to the RWH code, but
I don't understand it.

I run OS X 10.9 on an early 2011 MBP.

Many thanks,
Jeff
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.haskell.org/pipermail/haskell-cafe/attachments/20141020/035f16b4/attachment.html>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: syslogclient.hs
Type: application/octet-stream
Size: 2039 bytes
Desc: not available
URL: <http://www.haskell.org/pipermail/haskell-cafe/attachments/20141020/035f16b4/attachment.obj>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: SyslogTypes.hs
Type: application/octet-stream
Size: 3019 bytes
Desc: not available
URL: <http://www.haskell.org/pipermail/haskell-cafe/attachments/20141020/035f16b4/attachment-0001.obj>


More information about the Haskell-Cafe mailing list