Liking cljdoc? Tell your friends :D

clunk.byte-buffer-socket


close-buffer-socketclj/s≠

(close-buffer-socket {:keys [client]})
clj

Idempotent.

Idempotent.
source (clj)source (cljs)raw docstring

connected?clj/s≠

(connected? client)
cljs

True until the socket is destroyed, as it is once the server hangs up. Writes made while it is still connecting are buffered.

True until the socket is destroyed, as it is once the server hangs up.
Writes made while it is still connecting are buffered.
source (clj)source (cljs)raw docstring

get-buffer-socketclj/s≠

(get-buffer-socket port address ssl)
clj

Connects, blocking until the connection, and its TLS handshake if ssl asks for one, is ready. ssl is nil, or the TLS settings clunk.tls/connect takes. Throws if either fails.

Connects, blocking until the connection, and its TLS handshake if ssl asks
for one, is ready. ssl is nil, or the TLS settings clunk.tls/connect
takes. Throws if either fails.
cljs

Starts connecting and returns at once; writes wait until the connection is ready. ssl is nil, or the TLS settings clunk.tls/connect takes.

Starts connecting and returns at once; writes wait until the connection is
ready. ssl is nil, or the TLS settings clunk.tls/connect takes.
source (clj)source (cljs)raw docstring

pauseclj/s≠

clj
(pause _)
cljs
(pause {:keys [client]})

Stops reading until resume, so a slow reader pushes back on the server.

Stops reading until resume, so a slow reader pushes back on the server.
source (clj)source (cljs)raw docstring

resumeclj/s≠

clj
(resume _)
cljs
(resume {:keys [client]})
source (clj)source (cljs)

start!clj/s≠

clj
(start! {:keys [client reader-name]} on-chunk on-close)

Calls on-chunk with each chunk read, as a byte array, then on-close once, when the connection ends. Both run on the connection's own thread, named clunk-reader-<host>:<port>, which reads for as long as the connection is open, idle or not, so it sees messages the server sends unasked and notices a server that hangs up. on-chunk may block it, which pushes back on the server.

It's a daemon platform thread, not a virtual one: on a 24-thread machine a platform reader handled up to half again as many small queries, at less than half the CPU each, since waking a virtual thread blocked on a socket also wakes the JDK's poller threads. A daemon, so a client nobody closed doesn't keep the JVM running.

Calls on-chunk with each chunk read, as a byte array, then on-close once,
when the connection ends. Both run on the connection's own thread, named
clunk-reader-<host>:<port>, which reads for as long as the connection is
open, idle or not, so it sees messages the server sends unasked and notices
a server that hangs up. on-chunk may block it, which pushes back on the
server.

It's a daemon platform thread, not a virtual one: on a 24-thread machine a
platform reader handled up to half again as many small queries, at less
than half the CPU each, since waking a virtual thread blocked on a socket
also wakes the JDK's poller threads. A daemon, so a client nobody closed
doesn't keep the JVM running.
cljs
(start! {:keys [client]} on-chunk on-close)

Calls on-chunk with each chunk read, as an ArrayBuffer, then on-close once the connection ends.

Calls on-chunk with each chunk read, as an ArrayBuffer, then on-close once
the connection ends.
source (clj)source (cljs)raw docstring

write!clj/s≠

(write! {:keys [client]} bs)
clj

Writes a ByteBuffer whose position is at the end of its bytes, on the caller's thread. SocketChannel and SSLSocket each keep concurrent writes whole. clunk writes a query only once the server has answered the last one, so the socket's send buffer is empty and only a request larger than it waits for the server to read.

Writes a ByteBuffer whose position is at the end of its bytes, on the
caller's thread. SocketChannel and SSLSocket each keep concurrent writes
whole. clunk writes a query only once the server has answered the last
one, so the socket's send buffer is empty and only a request larger than
it waits for the server to read.
cljs

Writes a binf view (a DataView); Node buffers what the socket can't take yet.

Writes a binf view (a DataView); Node buffers what the socket can't take yet.
source (clj)source (cljs)raw 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