Skip to content

Instantly share code, notes, and snippets.

@lfranchi
Created October 8, 2012 21:15
Show Gist options
  • Save lfranchi/3855027 to your computer and use it in GitHub Desktop.
Save lfranchi/3855027 to your computer and use it in GitHub Desktop.
(defn listen
"UDP listener"
[_]
(let [buf (byte-array dgram-size)
packet (DatagramPacket. buf dgram-size)]
(dosync
(.receive @udp-sock packet)
(println "Received packet: " (String. (.getData packet) 0 (.getLength packet)))))
(send udp-listener listen))
(defn listen
"UDP listener"
[_]
(let [buf (byte-array dgram-size)
packet (DatagramPacket. buf dgram-size)
strval (dosync (.receive @udp-sock packet) (String. (.getData packet) 0 (.getLength packet)))]
(println "Received packet:" strval)
(send udp-listener listen)))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment