EgretDoc
Back to Home
Location:system/net.tls

Module

Module documentation.

modulenet.tls

Classes

Classes and inheritance.

classnet.tls::Conn
@brief`Conn` type.
@details`Conn` encapsulates state and operations exported by the system module. It commonly stores runtime handles, protocol state, buffers, configuration, or collection data. Its methods define the primary behavior for the type. If the type owns external resources, prefer `dispose` or `close` for deterministic release.
class Conn {
    /*
    @brief `h` field.

Functions

Free functions and class methods.

functionnet.tls::__tls_connect
Signatureextern func __tls_connect(host: String, port: Int, timeout_ms: Int) -> Int;
extern func __tls_connect(host: String, port: Int, timeout_ms: Int) -> Int;
/*
@brief Binds the low-level runtime symbol `__tls_upgrade_client_fd`.
@briefBinds the low-level runtime symbol `__tls_connect`.
@detailsThis function is an external entry point used by system modules to access native runtime capabilities such as filesystem, networking, threading, GC, cryptography, or platform operations. Prefer the safe wrapper functions in the same file when available. When calling this entry directly, pass validated arguments that match the signature and handle failures according to the return-value convention.
@param
  • hostHost name or listen address.
  • portPort number.
  • timeout_msTimeout in milliseconds; negative values usually select blocking or default timeout behavior.
@returnReturns the operation result as `Int`.
functionnet.tls::__tls_upgrade_client_fd
Signatureextern func __tls_upgrade_client_fd(fd: Int, host: String, timeout_ms: Int) -> Int;
extern func __tls_upgrade_client_fd(fd: Int, host: String, timeout_ms: Int) -> Int;
/*
@brief Binds the low-level runtime symbol `__tls_upgrade_client_fd_ex`.
@briefBinds the low-level runtime symbol `__tls_upgrade_client_fd`.
@detailsThis function is an external entry point used by system modules to access native runtime capabilities such as filesystem, networking, threading, GC, cryptography, or platform operations. Prefer the safe wrapper functions in the same file when available. When calling this entry directly, pass validated arguments that match the signature and handle failures according to the return-value convention.
@param
  • fdOperating-system file descriptor or socket descriptor.
  • hostHost name or listen address.
  • timeout_msTimeout in milliseconds; negative values usually select blocking or default timeout behavior.
@returnReturns the operation result as `Int`.
functionnet.tls::__tls_upgrade_client_fd_ex
Signatureextern func __tls_upgrade_client_fd_ex(fd: Int, host: String, timeout_ms: Int, verify: Int, ca_file: String) -> Int;
extern func __tls_upgrade_client_fd_ex(fd: Int, host: String, timeout_ms: Int, verify: Int, ca_file: String) -> Int;
/*
@brief Binds the low-level runtime symbol `__tls_send`.
@briefBinds the low-level runtime symbol `__tls_upgrade_client_fd_ex`.
@detailsThis function is an external entry point used by system modules to access native runtime capabilities such as filesystem, networking, threading, GC, cryptography, or platform operations. Prefer the safe wrapper functions in the same file when available. When calling this entry directly, pass validated arguments that match the signature and handle failures according to the return-value convention.
@param
  • fdOperating-system file descriptor or socket descriptor.
  • hostHost name or listen address.
  • timeout_msTimeout in milliseconds; negative values usually select blocking or default timeout behavior.
  • verifyWhether certificate or identity verification is required for the TLS operation.
  • ca_fileFilesystem path to the certificate authority bundle used for TLS verification.
@returnReturns the operation result as `Int`.
functionnet.tls::__tls_send
Signatureextern func __tls_send(h: Int, data: String, timeout_ms: Int) -> Int;
extern func __tls_send(h: Int, data: String, timeout_ms: Int) -> Int;
/*
@brief Binds the low-level runtime symbol `__tls_recv`.
@briefBinds the low-level runtime symbol `__tls_send`.
@detailsThis function is an external entry point used by system modules to access native runtime capabilities such as filesystem, networking, threading, GC, cryptography, or platform operations. Prefer the safe wrapper functions in the same file when available. When calling this entry directly, pass validated arguments that match the signature and handle failures according to the return-value convention.
@param
  • hUnderlying runtime handle.
  • dataInput or output data buffer.
  • timeout_msTimeout in milliseconds; negative values usually select blocking or default timeout behavior.
@returnReturns the operation result as `Int`.
functionnet.tls::__tls_recv
Signatureextern func __tls_recv(h: Int, max_bytes: Int, timeout_ms: Int) -> String;
extern func __tls_recv(h: Int, max_bytes: Int, timeout_ms: Int) -> String;
/*
@brief Binds the low-level runtime symbol `__tls_close`.
@briefBinds the low-level runtime symbol `__tls_recv`.
@detailsThis function is an external entry point used by system modules to access native runtime capabilities such as filesystem, networking, threading, GC, cryptography, or platform operations. Prefer the safe wrapper functions in the same file when available. When calling this entry directly, pass validated arguments that match the signature and handle failures according to the return-value convention.
@param
  • hUnderlying runtime handle.
  • max_bytesMaximum number of bytes to read or process in this operation.
  • timeout_msTimeout in milliseconds; negative values usually select blocking or default timeout behavior.
@returnReturns the operation result as `String`.
functionnet.tls::__tls_close
Signatureextern func __tls_close(h: Int) -> Void;
extern func __tls_close(h: Int) -> Void;

/*
@briefBinds the low-level runtime symbol `__tls_close`.
@detailsThis function is an external entry point used by system modules to access native runtime capabilities such as filesystem, networking, threading, GC, cryptography, or platform operations. Prefer the safe wrapper functions in the same file when available. When calling this entry directly, pass validated arguments that match the signature and handle failures according to the return-value convention.
@param
  • hUnderlying runtime handle.
@returnVoid
functionnet.tls::tls_connect
Signaturefunc tls_connect(host: String, port: Int, timeout_ms: Int) -> Int
func tls_connect(host: String, port: Int, timeout_ms: Int) -> Int {
    return __tls_connect(host, port, timeout_ms);
}
@briefProvides the system library operation `tls_connect`.
@detailsExecutes the `tls_connect` system-library API. The documented parameters define the accepted inputs, ownership requirements, range limits, and timeout behavior for this call. Callers must check returned `ErrCode` values or boolean status values before using the result.
@param
  • hostHost name or listen address.
  • portPort number.
  • timeout_msTimeout in milliseconds; negative values usually select blocking or default timeout behavior.
@returnReturns the operation result as `Int`.
functionnet.tls::tls_upgrade_client_fd
Signaturefunc tls_upgrade_client_fd(fd: Int, host: String, timeout_ms: Int) -> Int
func tls_upgrade_client_fd(fd: Int, host: String, timeout_ms: Int) -> Int {
    return __tls_upgrade_client_fd(fd, host, timeout_ms);
}
@briefProvides the system library operation `tls_upgrade_client_fd`.
@detailsExecutes the `tls_upgrade_client_fd` system-library API. The documented parameters define the accepted inputs, ownership requirements, range limits, and timeout behavior for this call. Callers must check returned `ErrCode` values or boolean status values before using the result.
@param
  • fdOperating-system file descriptor or socket descriptor.
  • hostHost name or listen address.
  • timeout_msTimeout in milliseconds; negative values usually select blocking or default timeout behavior.
@returnReturns the operation result as `Int`.
functionnet.tls::tls_upgrade_client_fd_ex
Signaturefunc tls_upgrade_client_fd_ex(fd: Int, host: String, timeout_ms: Int, verify: Int, ca_file: String) -> Int
func tls_upgrade_client_fd_ex(fd: Int, host: String, timeout_ms: Int, verify: Int, ca_file: String) -> Int {
    return __tls_upgrade_client_fd_ex(fd, host, timeout_ms, verify, ca_file);
}
@briefProvides the system library operation `tls_upgrade_client_fd_ex`.
@detailsExecutes the `tls_upgrade_client_fd_ex` system-library API. The documented parameters define the accepted inputs, ownership requirements, range limits, and timeout behavior for this call. Callers must check returned `ErrCode` values or boolean status values before using the result.
@param
  • fdOperating-system file descriptor or socket descriptor.
  • hostHost name or listen address.
  • timeout_msTimeout in milliseconds; negative values usually select blocking or default timeout behavior.
  • verifyWhether certificate or identity verification is required for the TLS operation.
  • ca_fileFilesystem path to the certificate authority bundle used for TLS verification.
@returnReturns the operation result as `Int`.
functionnet.tls::tls_send
Signaturefunc tls_send(h: Int, data: String, timeout_ms: Int) -> Int
func tls_send(h: Int, data: String, timeout_ms: Int) -> Int {
    return __tls_send(h, data, timeout_ms);
}
@briefProvides the system library operation `tls_send`.
@detailsExecutes the `tls_send` system-library API. The documented parameters define the accepted inputs, ownership requirements, range limits, and timeout behavior for this call. Callers must check returned `ErrCode` values or boolean status values before using the result.
@param
  • hUnderlying runtime handle.
  • dataInput or output data buffer.
  • timeout_msTimeout in milliseconds; negative values usually select blocking or default timeout behavior.
@returnReturns the operation result as `Int`.
functionnet.tls::tls_recv
Signaturefunc tls_recv(h: Int, max_bytes: Int, timeout_ms: Int) -> String
func tls_recv(h: Int, max_bytes: Int, timeout_ms: Int) -> String {
    return __tls_recv(h, max_bytes, timeout_ms);
}
@briefProvides the system library operation `tls_recv`.
@detailsExecutes the `tls_recv` system-library API. The documented parameters define the accepted inputs, ownership requirements, range limits, and timeout behavior for this call. Callers must check returned `ErrCode` values or boolean status values before using the result.
@param
  • hUnderlying runtime handle.
  • max_bytesMaximum number of bytes to read or process in this operation.
  • timeout_msTimeout in milliseconds; negative values usually select blocking or default timeout behavior.
@returnReturns the operation result as `String`.
functionnet.tls::tls_close
Signaturefunc tls_close(h: Int) -> Void
func tls_close(h: Int) -> Void {
    _ = __tls_close(h);
}
@briefProvides the system library operation `tls_close`.
@detailsExecutes the `tls_close` system-library API. The documented parameters define the accepted inputs, ownership requirements, range limits, and timeout behavior for this call. Callers must check returned `ErrCode` values or boolean status values before using the result.
@param
  • hUnderlying runtime handle.
@returnVoid
functionnet.tls::Conn.init
Signaturefunc init(self: net.tls.Conn, h: Int = 0, owns_handle: Bool = true) -> Void
    func init(self: net.tls.Conn, h: Int = 0, owns_handle: Bool = true) -> Void {
        self.h = h;
        self.closed = false;
@briefInitializes a `Conn` instance.
@detailsEstablishes the initial field state for `Conn` so other methods can be called safely. Constructor logic should keep fields consistent and avoid leaking partially initialized resources.
@param
  • selfThe current instance whose fields, handles, buffers, or external resources are read or modified by this method.
  • hUnderlying runtime handle.
  • owns_handleWhether the object owns the native handle and must release it during cleanup.
@returnVoid
functionnet.tls::Conn.close
Signaturefunc close(self: net.tls.Conn) -> Void
    func close(self: net.tls.Conn) -> Void {
        if !self.closed && self.h > 0 {
            _ = __tls_close(self.h);
@briefCloses resources and makes later operations unavailable with `Conn.close`.
@detailsExecutes the `close` system-library API. The documented parameters define the accepted inputs, ownership requirements, range limits, and timeout behavior for this call. Callers must check returned `ErrCode` values or boolean status values before using the result.
@param
  • selfThe current instance whose fields, handles, buffers, or external resources are read or modified by this method.
@returnVoid
functionnet.tls::Conn.dispose
Signaturefunc dispose(self: net.tls.Conn) -> Void
    func dispose(self: net.tls.Conn) -> Void {
        _ = self.close();
    }
@briefExplicitly releases resources owned by `Conn`.
@detailsThis method deterministically cleans up file descriptors, network connections, native handles, buffers, or other external resources. Implementations should be idempotent where possible, and repeated calls must not corrupt object state.
@param
  • selfThe current instance whose fields, handles, buffers, or external resources are read or modified by this method.
@returnVoid
functionnet.tls::Conn.deinit
Signaturefunc deinit(self: net.tls.Conn) -> Void
    func deinit(self: net.tls.Conn) -> Void {
        if self.owns_handle && !self.closed && self.h > 0 {
            _ = self.close();
@briefReleases fallback resources at the end of the `Conn` lifetime.
@detailsThis destructor hook is called by object lifetime management to clean up underlying resources that were not released explicitly. Normal application code should prefer `dispose`, `close`, or the module-specific close function to release resources at a deterministic time.
@param
  • selfThe current instance whose fields, handles, buffers, or external resources are read or modified by this method.
@returnVoid
functionnet.tls::connect
Signaturefunc connect(host: String, port: Int, timeout_ms: Int = -1) -> Int, ErrCode
func connect(host: String, port: Int, timeout_ms: Int = -1) -> Int, ErrCode {
    _ = net.clear_last_error();
    let h: Int = __tls_connect(host, port, timeout_ms);
@briefEstablishes a connection with `connect`.
@detailsExecutes the `connect` system-library API. The documented parameters define the accepted inputs, ownership requirements, range limits, and timeout behavior for this call. Callers must check returned `ErrCode` values or boolean status values before using the result.
@param
  • hostHost name or listen address.
  • portPort number.
  • timeout_msTimeout in milliseconds; negative values usually select blocking or default timeout behavior.
@returnReturns `Int, ErrCode`; on success the error code is `std.OK` or `OK`, and on failure the error code describes the failure while any returned value contains the usable partial result when available.
functionnet.tls::upgrade_client_fd
Signaturefunc upgrade_client_fd(fd: Int, host: String, timeout_ms: Int = -1) -> Int, ErrCode
func upgrade_client_fd(fd: Int, host: String, timeout_ms: Int = -1) -> Int, ErrCode {
    _ = net.clear_last_error();
    let h: Int = __tls_upgrade_client_fd(fd, host, timeout_ms);
@briefProvides the system library operation `upgrade_client_fd`.
@detailsExecutes the `upgrade_client_fd` system-library API. The documented parameters define the accepted inputs, ownership requirements, range limits, and timeout behavior for this call. Callers must check returned `ErrCode` values or boolean status values before using the result.
@param
  • fdOperating-system file descriptor or socket descriptor.
  • hostHost name or listen address.
  • timeout_msTimeout in milliseconds; negative values usually select blocking or default timeout behavior.
@returnReturns `Int, ErrCode`; on success the error code is `std.OK` or `OK`, and on failure the error code describes the failure while any returned value contains the usable partial result when available.
functionnet.tls::upgrade_client_fd_ex
Signaturefunc upgrade_client_fd_ex(fd: Int, host: String, timeout_ms: Int = -1, verify: Bool = false, ca_file: String = "") -> Int, ErrCode
func upgrade_client_fd_ex(fd: Int, host: String, timeout_ms: Int = -1, verify: Bool = false, ca_file: String = "") -> Int, ErrCode {
    _ = net.clear_last_error();
    let verify_flag: Int = 0;
@briefProvides the system library operation `upgrade_client_fd_ex`.
@detailsExecutes the `upgrade_client_fd_ex` system-library API. The documented parameters define the accepted inputs, ownership requirements, range limits, and timeout behavior for this call. Callers must check returned `ErrCode` values or boolean status values before using the result.
@param
  • fdOperating-system file descriptor or socket descriptor.
  • hostHost name or listen address.
  • timeout_msTimeout in milliseconds; negative values usually select blocking or default timeout behavior.
  • verifyWhether certificate or identity verification is required for the TLS operation.
  • ca_fileFilesystem path to the certificate authority bundle used for TLS verification.
@returnReturns `Int, ErrCode`; on success the error code is `std.OK` or `OK`, and on failure the error code describes the failure while any returned value contains the usable partial result when available.
functionnet.tls::send
Signaturefunc send(h: Int, data: String, timeout_ms: Int = -1) -> Int, ErrCode
func send(h: Int, data: String, timeout_ms: Int = -1) -> Int, ErrCode {
    _ = net.clear_last_error();
    let n: Int = __tls_send(h, data, timeout_ms);
@briefSends data with `send`.
@detailsExecutes the `send` system-library API. The documented parameters define the accepted inputs, ownership requirements, range limits, and timeout behavior for this call. Callers must check returned `ErrCode` values or boolean status values before using the result.
@param
  • hUnderlying runtime handle.
  • dataInput or output data buffer.
  • timeout_msTimeout in milliseconds; negative values usually select blocking or default timeout behavior.
@returnReturns `Int, ErrCode`; on success the error code is `std.OK` or `OK`, and on failure the error code describes the failure while any returned value contains the usable partial result when available.
functionnet.tls::recv
Signaturefunc recv(h: Int, max_bytes: Int, timeout_ms: Int = -1) -> String, ErrCode
func recv(h: Int, max_bytes: Int, timeout_ms: Int = -1) -> String, ErrCode {
    _ = net.clear_last_error();
    let s: String = __tls_recv(h, max_bytes, timeout_ms);
@briefReceives data with `recv`.
@detailsExecutes the `recv` system-library API. The documented parameters define the accepted inputs, ownership requirements, range limits, and timeout behavior for this call. Callers must check returned `ErrCode` values or boolean status values before using the result.
@param
  • hUnderlying runtime handle.
  • max_bytesMaximum number of bytes to read or process in this operation.
  • timeout_msTimeout in milliseconds; negative values usually select blocking or default timeout behavior.
@returnReturns `String, ErrCode`; on success the error code is `std.OK` or `OK`, and on failure the error code describes the failure while any returned value contains the usable partial result when available.
functionnet.tls::close
Signaturefunc close(h: Int) -> Void
func close(h: Int) -> Void {
    _ = __tls_close(h);
    return;
@briefCloses resources and makes later operations unavailable with `close`.
@detailsExecutes the `close` system-library API. The documented parameters define the accepted inputs, ownership requirements, range limits, and timeout behavior for this call. Callers must check returned `ErrCode` values or boolean status values before using the result.
@param
  • hUnderlying runtime handle.
@returnVoid

Variables

Class fields (var).

varnet.tls::Conn.h
TypeInt
@brief`h` field.
@detailsStores the underlying runtime handle. The field type is `Int`, and it is maintained by the constructors and methods of `Conn`.
    var h: Int;
    /*
    @brief `closed` field.
varnet.tls::Conn.closed
TypeBool
@brief`closed` field.
@detailsIndicates whether the resource has already been closed. The field type is `Bool`, and it is maintained by the constructors and methods of `Conn`.
    var closed: Bool;
    /*
    @brief `owns_handle` field.
varnet.tls::Conn.owns_handle
TypeBool
@brief`owns_handle` field.
@detailsIndicates whether the object owns and must release the underlying handle. The field type is `Bool`, and it is maintained by the constructors and methods of `Conn`.
    var owns_handle: Bool;

    /*