Created
October 8, 2012 21:15
-
-
Save lfranchi/3855027 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(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