AtomicSocket

trait AtomicSocket[F[_]]

An abstraction of Socket objects that satisfies stronger specifications in return for a restricted interface.

Companion
object
class Object
trait Matchable
class Any

Value members

Abstract methods

def readN(size: Int): F[Chunk[Byte]]

Reads precisely size byte from the underlying Socket. The action semantically blocks until a chunk of the specified size is available.

Reads precisely size byte from the underlying Socket. The action semantically blocks until a chunk of the specified size is available.

This action is cancellable and atomic. When the action errored (as in the case described below) or has been cancelled before a readN operation is complete, this AtomicSocket returns to the identical state as before.

If the underlying Socket cannot fulfil the size-constraint due to (for example) connection being closed, then this action results in an java.io.IOException.

This action is isolated in a sense that two concurrent readNs will be linearlized in some order: even if readN(n) and readN(m) are concurrently run, the result of the first (resp. second) action is guaranteed to be a continuous n (resp. m) bytes from the Socket.

def write(chunk: Chunk[Byte]): F[Unit]

Writes chunk to the peer. This action completes when the bytes are written to the underlying Socket. However, it is not guaranteed that all bytes have been written upon completion, since the socket may be closed during a write operation.

Writes chunk to the peer. This action completes when the bytes are written to the underlying Socket. However, it is not guaranteed that all bytes have been written upon completion, since the socket may be closed during a write operation.

This is an uncancellable an hence an atomic action.

This action is isolated in a sense that two concurrent writes will be linearlized in some order: even if write(c1) and write(c2) are concurrently run, the bytes written to the underlying socket will not be a mixture of c1 and c2, but rather a (technically, an initial segment of) concatenation of c1 and c2 or of c2 and c1.