init commit
This commit is contained in:
@@ -0,0 +1,68 @@
|
||||
(ns inet
|
||||
"Erlang :inet module — network interface configuration.
|
||||
|
||||
In CljElixir: (inet/setopts socket opts), (inet/port socket), etc.")
|
||||
|
||||
(defn setopts
|
||||
"Sets socket options.
|
||||
(inet/setopts socket [{:active true}])
|
||||
(inet/setopts socket [{:packet :line}])"
|
||||
[socket opts])
|
||||
|
||||
(defn getopts
|
||||
"Gets socket options.
|
||||
(inet/getopts socket [:active :packet])"
|
||||
[socket opts])
|
||||
|
||||
(defn port
|
||||
"Returns the port number of a socket.
|
||||
(inet/port socket) ;=> {:ok 4000}"
|
||||
[socket])
|
||||
|
||||
(defn peername
|
||||
"Returns {address port} of the remote end.
|
||||
(inet/peername socket) ;=> {:ok {{127 0 0 1} 4000}}"
|
||||
[socket])
|
||||
|
||||
(defn sockname
|
||||
"Returns {address port} of the local end.
|
||||
(inet/sockname socket) ;=> {:ok {{0 0 0 0} 4000}}"
|
||||
[socket])
|
||||
|
||||
(defn getaddr
|
||||
"Resolves hostname to IP address.
|
||||
(inet/getaddr \"localhost\" :inet) ;=> {:ok {127 0 0 1}}"
|
||||
[hostname family])
|
||||
|
||||
(defn gethostname
|
||||
"Returns the hostname of the local machine.
|
||||
(inet/gethostname) ;=> {:ok \"myhost\"}"
|
||||
[])
|
||||
|
||||
(defn getifaddrs
|
||||
"Returns network interface addresses.
|
||||
(inet/getifaddrs) ;=> {:ok [...]}"
|
||||
[])
|
||||
|
||||
(defn parse-address
|
||||
"Parses an IP address string.
|
||||
(inet/parse-address \"192.168.1.1\") ;=> {:ok {192 168 1 1}}"
|
||||
[address])
|
||||
|
||||
(defn ntoa
|
||||
"Converts IP tuple to string.
|
||||
(inet/ntoa {192 168 1 1}) ;=> '192.168.1.1'"
|
||||
[ip])
|
||||
|
||||
(defn close
|
||||
"Closes a socket."
|
||||
[socket])
|
||||
|
||||
(defn controlling-process
|
||||
"Transfers socket control to another process."
|
||||
[socket pid])
|
||||
|
||||
(defn i
|
||||
"Prints information about all open sockets."
|
||||
([])
|
||||
([proto]))
|
||||
Reference in New Issue
Block a user