(accept this opts)
Accept a new connection on a server socket. Returns a promise channel that will yield a new AsynchronousSocketChannel, or an anomaly on error.
Accept a new connection on a server socket. Returns a promise channel that will yield a new AsynchronousSocketChannel, or an anomaly on error.
(connect this address opts)
Asynchronously connect to an address.
Returns a promise channel that will yield an empty map on connect. The channel returns an anomaly on error.
Opts is currently unused.
Asynchronously connect to an address. Returns a promise channel that will yield an empty map on connect. The channel returns an anomaly on error. Opts is currently unused.
(read this opts)
Asynchronously read bytes from a channel. Returns a promise channel that will yield a map containing values:
The channel returns an anomaly on error.
Options map may include:
Asynchronously read bytes from a channel. Returns a promise channel that will yield a map containing values: - :length - the number of bytes read, or a negative value if the channel is closed. - :buffer - the ByteBuffer containing the bytes read. The channel returns an anomaly on error. Options map may include: - :length - the number of bytes to read. Specify this or buffer. - :buffer - a ByteBuffer to read into. Will attempt to read as many bytes as available in the buffer. - :timeout - an integer, the timeout, default 0 (no timeout). Only supported for network channels. - :timeout-units - a TimeUnit, default milliseconds. - :position - an integer, the position to read in file channels.
(write this buffer opts)
Asynchronously write bytes to a channel. Returns a promise channel that will yield a map containing values:
The channel returns an anomaly on error.
Options map may include:
Asynchronously write bytes to a channel. Returns a promise channel that will yield a map containing values: - :length - the number of bytes written. The channel returns an anomaly on error. Options map may include: - :timeout - an integer, the timeout, default 0 (no timeout). Only valid for network channels. - :timeout-units - a TimeUnit, default milliseconds
(exception-handler exception channel)
(server handler
{:keys [backlog bind-address buffer-size]
:or {backlog 0
bind-address (InetSocketAddress. (InetAddress/getLocalHost) 0)
buffer-size 1024}})
Create a server socket channel, which will constantly accept connections and will pass each new connection to the function handler. Each connection passed will be as passed through wrap-socket.
Options include:
Returns a map of values:
Create a server socket channel, which will constantly accept connections and will pass each new connection to the function handler. Each connection passed will be as passed through wrap-socket. Options include: - :backlog - the server socket backlog, default 0. - :bind-address - address to bind to, defaults to localhost with a port of 0 (a random port). - :buffer-size - the buffer size per connection. Defaults to 1024. Returns a map of values: - :socket - The server socket channel. - :close-chan - A channel that, when closed, will close the server. - :server-chan - A channel that will close when the server channel is closed.
(socket-channel address {:keys [buffer-size] :or {buffer-size 1024} :as opts})
Create a socket channel, connect, and return a pair of channels for communicating with this socket.
Returns a channel that will yield a map with keys:
On error, returns an anomaly.
If an error occurs while reading or writing, and anomaly will be passed to the recv channel, and the channels and socket will be closed.
Closing the send channel will close the socket.
Create a socket channel, connect, and return a pair of channels for communicating with this socket. Returns a channel that will yield a map with keys: - :send - The channel to send ByteBuffers to the channel. - :recv - The channel to receive ByteBuffers from the channel. - :socket - The AsynchronousSocketChannel. On error, returns an anomaly. If an error occurs while reading or writing, and anomaly will be passed to the recv channel, and the channels and socket will be closed. Closing the send channel will close the socket.
(wrap-socket socket {:keys [buffer-size] :or {buffer-size 1024}})
cljdoc is a website building & hosting documentation for Clojure/Script libraries
× close