kex docs Standard Library

Net

module Net

Shared networking values, capability discovery, and typed failures.

using Net

let https = Port.from(443).try
if Support.current.tls.usable? then https.string else "TLS unavailable" end

record Port

A validated TCP or UDP port number in 0..65535.

Use Port.from at input boundaries. Port zero requests an ephemeral port where a listening API permits it.

Fields

value
Integer

Methods

string

string : String

Renders the decimal port without a host or scheme.

Returns decimal port text

record SupportValue

Whether a feature was compiled into this backend and is usable now.

Fields

compiled?
Bool
usable?
Bool

record SupportReport

Granular networking capabilities for the current backend and environment.

Fields

httpClient
SupportValue
httpServer
SupportValue
webSocketClient
SupportValue
webSocketServer
SupportValue

module Net.Port

from

from(value: Integer) -> Result<Port, NetError>

Validates a port number.

Parameters
value
a number in 0..65535

Returns the validated port, or Parse

Examples

+Port.from(443).try+.

module Net.Support

current constant

current : SupportReport

Reports compiled and currently usable networking features.

Examples

+Support.current.httpClient.usable?+.

type NetOperation

The subsystem or operation that produced a networking error.

Variants

  • DNS
  • TCP
  • UDP
  • Unix
  • TLS
  • HTTPClient
  • HTTPServer
  • WebSocketClient
  • WebSocketServer

type NetErrorKind

Stable, backend-independent networking failure categories.

Variants

  • Parse
  • Resolve
  • Connect
  • Protocol
  • Timeout
  • Cancelled
  • Limit
  • Closed
  • ReadInProgress
  • UnsupportedBackend
  • UnsupportedOption
  • BrowserRestricted
  • OpaqueRedirect
  • MockEmpty
  • Backend

record NetError

A typed networking failure. phase adds optional protocol context and progress records bytes transferred before a partial-operation failure.

Fields

operation
NetOperation
message
String
phase
String?
progress
Integer?

Submodules

  • Net.DNS Typed DNS lookup with explicit resolver ownership and bounded caching.
  • Net.HTTP Buffered HTTP clients, responses, and a small declaration-ordered server router. Requests never follow redirects or perform generic retries implicitly.
  • Net.HTTP.WebSocket High-level RFC 6455 client messages. The runtime handles fragmentation and ping/pong frames; reconnect and heartbeat policies remain application-owned.
  • Net.IP Validated, canonical IP addresses and CIDR networks.
  • Net.Socket Process-owned TCP byte streams and listeners. All blocking operations return typed NetError values; close operations are idempotent.