Package-level declarations

Types

Link copied to clipboard
Link copied to clipboard
Link copied to clipboard

In-band commands. TCP urgent-data SYNCH is deliberately not represented.

Link copied to clipboard
class TelnetConfig(terminalTypes: List<String> = listOf("UNKNOWN"), val columns: Int = 0, val rows: Int = 0, val profile: TelnetProfile = TelnetProfile.PASSIVE, val nonBinaryPolicy: NonBinaryPolicy = NonBinaryPolicy.STRICT_ASCII, val newlinePolicy: NewlinePolicy = NewlinePolicy.PRESERVE_LF, val consumeRecords: Boolean = false, val charset: String? = null, val maxSubnegotiationBytes: Int = 64 * 1024, val inputBudgetBytes: Int = 256 * 1024, val outputBudgetBytes: Int = 256 * 1024, val maxPendingEvents: Int = 8192, val controlBudgetBytes: Int = 32 * 1024, val charsetTimeoutMillis: Long, val closeTimeoutMillis: Long)

Immutable protocol settings. Terminal capabilities must match the actual emulator.

Link copied to clipboard

Negotiation direction: LOCAL is WILL/WONT; REMOTE is DO/DONT.

Link copied to clipboard
sealed interface TelnetEffect

An ordered effect. Outbound arrays are complete frames owned by their recipient.

Link copied to clipboard

Deterministic, single-owner client engine. No sockets, callbacks, or coroutine state. Feed at most CHUNK_SIZE bytes per step; repeat with the unconsumed suffix. A result consumes input or reports a terminal failure; empty input is a no-op. Call start once before other operations and finish once at peer EOF. Invalid slices, dimensions and oversized writes throw IllegalArgumentException. Starting twice or using an unstarted engine throws IllegalStateException.

Link copied to clipboard
data class TelnetFailure(val code: TelnetFailureCode, val message: String)

An operational failure returned as data; argument and state preconditions still throw.

Link copied to clipboard

Stable failure categories returned at public API boundaries.

Link copied to clipboard
sealed interface TelnetInput

Lossless, ordered application input; each Data owns its array.

Link copied to clipboard

Options supported by the Telnet client.

Link copied to clipboard
sealed interface TelnetOutcome<out T>
Link copied to clipboard
Link copied to clipboard
data class TelnetResult(val consumed: Int, val effects: List<TelnetEffect>, val failure: TelnetFailure? = null)

A bounded processing step, including complete effects preceding any failure.

Link copied to clipboard
interface TelnetSession

Ordered, single-consumer input and concurrent suspend output operations.

Link copied to clipboard
data class TelnetSnapshot(val status: TelnetStatus = TelnetStatus.OPEN, val localEcho: Boolean = true, val incomingBinary: Boolean = false, val outgoingBinary: Boolean = false, val charset: String? = null, val charsetPending: Boolean = false, val failure: TelnetFailure? = null)
Link copied to clipboard
Link copied to clipboard
interface TelnetTransport

A duplex byte transport. Positive reads make progress; -1 is EOF, zero is only legal for a zero-length request. Write must finish the entire slice. Close must promptly interrupt a suspended read/write and be safe to call repeatedly.

Functions

Link copied to clipboard
fun createTelnetEngine(config: TelnetConfig = TelnetConfig()): TelnetEngine

Creates a fresh engine after validating configuration. Start it before feeding bytes.

Link copied to clipboard
fun openTelnetSession(scope: CoroutineScope, transport: TelnetTransport, config: TelnetConfig = TelnetConfig(), workerContext: CoroutineContext = scope.coroutineContext.minusKey(Job)): TelnetSession

Opens a child session over an already connected transport. The session owns and closes that transport. Each large write is accepted in independent bounded chunks, allowing negotiation and competing operations between chunks.