init commit
This commit is contained in:
@@ -0,0 +1,33 @@
|
||||
(ns gen_udp
|
||||
"Erlang :gen_udp module — UDP socket interface.
|
||||
|
||||
In CljElixir: (gen_udp/open port opts), (gen_udp/send socket addr port data), etc.")
|
||||
|
||||
(defn open
|
||||
"Opens a UDP socket. Returns {:ok socket} or {:error reason}.
|
||||
(gen_udp/open 0 [:binary {:active false}]) ;=> {:ok socket}"
|
||||
([port])
|
||||
([port opts]))
|
||||
|
||||
(defn send
|
||||
"Sends a UDP packet.
|
||||
(gen_udp/send socket \"localhost\" 4000 \"hello\")
|
||||
(gen_udp/send socket destination packet)"
|
||||
([socket destination packet])
|
||||
([socket host port packet]))
|
||||
|
||||
(defn recv
|
||||
"Receives a UDP packet. Returns {:ok {address port data}} or {:error reason}.
|
||||
(gen_udp/recv socket 0) ;=> {:ok {addr port data}}
|
||||
(gen_udp/recv socket 1024 5000) ;=> with timeout"
|
||||
([socket length])
|
||||
([socket length timeout]))
|
||||
|
||||
(defn close
|
||||
"Closes a UDP socket.
|
||||
(gen_udp/close socket) ;=> :ok"
|
||||
[socket])
|
||||
|
||||
(defn controlling-process
|
||||
"Transfers socket ownership to another process."
|
||||
[socket pid])
|
||||
Reference in New Issue
Block a user