Liking cljdoc? Tell your friends :D

teensyp.server

The main server namespace.

The main server namespace.
raw docstring

closeclj

(close socket)
(close socket callback)

Queue the supplied Socket to be closed. Accepts an optional, zero argument callback that will be run after the socket has been closed.

Queue the supplied Socket to be closed. Accepts an optional, zero argument
callback that will be run after the socket has been closed.
sourceraw docstring

force-readclj

(force-read socket)
(force-read socket callback)

Force a call to the read handler, even if no new data has arrived. This is a control event, and is limited by the :control-queue-size. Too many control events queued at once for a single Socket will throw an ExceptionInfo.

Force a call to the read handler, even if no new data has arrived. This is a
control event, and is limited by the `:control-queue-size`. Too many control
events queued at once for a single Socket will throw an ExceptionInfo.
sourceraw docstring

pause-readsclj

(pause-reads socket)
(pause-reads socket callback)

Pause reads for this Socket. See: resume-reads. This is a control event, and is limited by the :control-queue-size. Too many control events queued at once for a single Socket will throw an ExceptionInfo.

Pause reads for this Socket. See: [[resume-reads]]. This is a control event,
and is limited by the `:control-queue-size`. Too many control events queued
at once for a single Socket will throw an ExceptionInfo.
sourceraw docstring

resume-readsclj

(resume-reads socket)
(resume-reads socket callback)

Resume reads for this Socket. Forces a call to the read handler if any data is waiting on the socket buffer. See: pause-reads. This is a control event, and is limited by the :control-queue-size. Too many control events queued at once for a single Socket will throw an ExceptionInfo.

Resume reads for this Socket. Forces a call to the read handler if any
data is waiting on the socket buffer. See: [[pause-reads]]. This is a control
event, and is limited by the `:control-queue-size`. Too many control events
queued at once for a single Socket will throw an ExceptionInfo.
sourceraw docstring

Socketcljprotocol

A protocol representing a client socket. See also: write, close, pause-reads and resume-reads.

A protocol representing a client socket. See also: [[write]], [[close]],
[[pause-reads]] and [[resume-reads]].

queue-controlclj

(queue-control socket control callback)

Queue a control event, such as ::pause-reads or ::resume-reads.

Queue a control event, such as ::pause-reads or ::resume-reads.

queue-writeclj

(queue-write socket buffer callback)

Queue the buffer to be written to the socket. If the callback is not nil, it will be called as a zero argument function once the buffer has been written. See write for a more convenient way of calling this method.

Queue the buffer to be written to the socket. If the callback is not nil,
it will be called as a zero argument function once the buffer has been
written. See [[write]] for a more convenient way of calling this method.

socket-infoclj

(socket-info socket)

Return a map of information about the socket's connection. This includes keys for :local-address and :remote-address, which are immutable java.net.InetSocketAddress instances.

Return a map of information about the socket's connection. This includes
keys for :local-address and :remote-address, which are immutable
java.net.InetSocketAddress instances.
sourceraw docstring

start-serverclj

(start-server {:keys [port executor recv-buffer-size reuse-address?] :as opts})

Start a TCP server with the supplied map of options:

  • :port - the port number to listen on (mandatory)
  • :handler - a handler function (mandatory, see below)
  • :control-queue-size - the max number of queued control events (default 32)
  • :executor - a custom ExecutorService to supply worker threads
  • :read-buffer-size - the read buffer size in bytes (default 8K)
  • :recv-buffer-size - the receive buffer size (i.e. the SO_RCVBUF option)
  • :reuse-address? - sets the SO_REUSEADDR socket option (default false)
  • :write-buffer-size - the write buffer size in bytes (default 32K)
  • :write-queue-size - the max number of writes in the queue (default 64)

The handler function must have three arities:

(fn handler
  ([socket] initial-state)           ;; on socket accept
  ([state socket buffer] new-state)  ;; on socket read data
  ([state exception]))               ;; on socket close

The buffer is a java.nio.ByteBuffer instance, and socket is an object that satisfies the Socket protocol.

The state is a custom data structure that is returned when the accept or read arities are triggered. A different state is associated with each connection.

When closing, the exception may contain the exception that terminated the channel, or nil if the channel were terminated gracefully.

The handler function is guaranteed to execute in serial per channel. That is, the accept will always be first, the close will always be last, and reads will always be sequential.

Start a TCP server with the supplied map of options:

- `:port` - the port number to listen on (mandatory)
- `:handler` - a handler function (mandatory, see below)
- `:control-queue-size` - the max number of queued control events (default 32)
- `:executor` - a custom ExecutorService to supply worker threads
- `:read-buffer-size` - the read buffer size in bytes (default 8K)
- `:recv-buffer-size` - the receive buffer size (i.e. the SO_RCVBUF option)
- `:reuse-address?` - sets the SO_REUSEADDR socket option (default false)
- `:write-buffer-size` - the write buffer size in bytes (default 32K)
- `:write-queue-size` - the max number of writes in the queue (default 64)

The handler function must have three arities:

    (fn handler
      ([socket] initial-state)           ;; on socket accept
      ([state socket buffer] new-state)  ;; on socket read data
      ([state exception]))               ;; on socket close

The `buffer` is a java.nio.ByteBuffer instance, and `socket` is an object
that satisfies the [[Socket]] protocol.

The `state` is a custom data structure that is returned when the accept or
read arities are triggered. A different state is associated with each
connection.

When closing, the `exception` may contain the exception that terminated the
channel, or `nil` if the channel were terminated gracefully.

The handler function is guaranteed to execute in serial per channel. That is,
the accept will always be first, the close will always be last, and reads
will always be sequential.
sourceraw docstring

writeclj

(write socket buffer)
(write socket buffer callback)

Queue up a ByteBuffer to be written a socket defined by the Socket protocol. Accepts an optional, zero argument callback function that will be run after the buffer has been written. The maximum number of queued buffers per socket is governed by the :write-queue-size option, and the maximum size of bytes that can be held in all queued buffers is :write-buffer-size. Exceeding either of these limits will throw an ExceptionInfo.

Queue up a ByteBuffer to be written a socket defined by the Socket protocol.
Accepts an optional, zero argument callback function that will be run after
the buffer has been written. The maximum number of queued buffers per socket
is governed by the `:write-queue-size` option, and the maximum size of bytes
that can be held in *all* queued buffers is `:write-buffer-size`. Exceeding
either of these limits will throw an ExceptionInfo.
sourceraw docstring

cljdoc builds & hosts documentation for Clojure/Script libraries

Keyboard shortcuts
Ctrl+kJump to recent docs
Move to previous article
Move to next article
Ctrl+/Jump to the search field
× close