How to send a string somewhere via UDP

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... 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

On 10/21/14, Jeffrey Brown
There is a UDP library http://hackage.haskell.org/package/network-conduit-0.6.1.1/docs/Data-Conduit... for Haskell, which I presume could serve as an alternative to the RWH code, but I don't understand it.
Here's a fully working UDP echo server: http://www.haskell.org/pipermail/haskell-cafe/2007-January/021280.html No special package needed, merely import the humble, dependable Network.Socket. -- Kim-Ee

I have been going back and for between the UDP server code
http://www.haskell.org/pipermail/haskell-cafe/2007-January/021280.html
Kim pointed me toward and Hayoo for an hour. I can load it into GHCI, but I
understand neither how it works nor how to use it. If I knew how to use it
I could probably figure out a lot of how it works on my own. If I wanted
to, say, send the message "test" to localhost port 9000, how would I do
that?
On Mon, Oct 20, 2014 at 9:04 PM, Kim-Ee Yeoh
On 10/21/14, Jeffrey Brown
wrote: There is a UDP library < http://hackage.haskell.org/package/network-conduit-0.6.1.1/docs/Data-Conduit...
for Haskell, which I presume could serve as an alternative to the RWH code, but I don't understand it.
Here's a fully working UDP echo server:
http://www.haskell.org/pipermail/haskell-cafe/2007-January/021280.html
No special package needed, merely import the humble, dependable Network.Socket.
-- Kim-Ee

aiosc.send(('127.0.0.1', 9000), "This is a message from Python") )
isn't this sending an OSC packet? not a plain UDP packet? perhaps see http://hackage.haskell.org/package/hosc import Sound.OSC withMax = withTransport (openUDP "127.0.0.1" 9000) main = withMax (sendMessage (Message "/this-is-a-message-from-haskell" []))

Rohan, that worked! And the timing is, to the extent my perception can
tell, perfect! (I'm using threadDelay to create a rhythm, as described here
http://haskell.1045720.n5.nabble.com/Precise-timing-td5758272.html.)
This means I can use Haskell instead of Python or SuperCollider. I am
beside myself with excitement.
On Tue, Oct 21, 2014 at 3:56 PM, Rohan Drape
aiosc.send(('127.0.0.1', 9000), "This is a message from Python") )
isn't this sending an OSC packet? not a plain UDP packet?
perhaps see http://hackage.haskell.org/package/hosc
import Sound.OSC withMax = withTransport (openUDP "127.0.0.1" 9000) main = withMax (sendMessage (Message "/this-is-a-message-from-haskell" []))
_______________________________________________ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe

This means I can use Haskell instead of Python or SuperCollider.
haskell is excellent for writing music in, supercollider is too. alex hosts a "haskell-art" list at http://lurk.org/ that might be helpful, there's also the tidal list there... best, rohan

On 10/22/14, Jeffrey Brown
This means I can use Haskell instead of Python or SuperCollider. I am beside myself with excitement.
Glad you got going! :) You might want to look into the mailing lists Rohan suggested because I'm on some of them and I see they're super-supportive of projects like yours.

I already joined :)
On Wed, Oct 22, 2014 at 10:16 AM, Kim-Ee Yeoh
On 10/22/14, Jeffrey Brown
wrote: This means I can use Haskell instead of Python or SuperCollider. I am beside myself with excitement.
Glad you got going! :)
You might want to look into the mailing lists Rohan suggested because I'm on some of them and I see they're super-supportive of projects like yours.
participants (3)
-
Jeffrey Brown
-
Kim-Ee Yeoh
-
Rohan Drape