Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- (ns udp.core
- (:import (java.net DatagramSocket DatagramPacket InetAddress NetworkInterface MulticastSocket))
- (:gen-class))
- (def buf (byte-array 1024))
- (defn -main []
- (let [server-socket (MulticastSocket. 5353)]
- (doto server-socket
- (.setReuseAddress true)
- (.setNetworkInterface (NetworkInterface/getByName "eth1"))
- (.joinGroup (InetAddress/getByName "224.0.0.251"))
- (.receive (DatagramPacket. buf 1024)))
- (doto (DatagramSocket. 5353)
- (.send (DatagramPacket. buf 1024 (InetAddress/getByName "224.0.0.251") 5353))
- (.close))))
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement