EgretDoc
Back to Home
Location:system/net.unix.socket

Module

Module documentation.

modulenet.unix.socket

Classes

Classes and inheritance.

classnet.unix.socket::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 `fd` field.

Functions

Free functions and class methods.

functionnet.unix.socket::__unix_connect
Signatureextern func __unix_connect(path: String, timeout_ms: Int) -> Int;
extern func __unix_connect(path: String, timeout_ms: Int) -> Int;
/*
@brief Binds the low-level runtime symbol `__unix_listen`.
@briefBinds the low-level runtime symbol `__unix_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
  • pathFile or directory path.
  • timeout_msTimeout in milliseconds; negative values usually select blocking or default timeout behavior.
@returnReturns the operation result as `Int`.
functionnet.unix.socket::__unix_listen
Signatureextern func __unix_listen(path: String, backlog: Int) -> Int;
extern func __unix_listen(path: String, backlog: Int) -> Int;
/*
@brief Binds the low-level runtime symbol `__unix_accept`.
@briefBinds the low-level runtime symbol `__unix_listen`.
@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
  • pathFile or directory path.
  • backlogMaximum number of pending inbound connections accepted by the listening socket.
@returnReturns the operation result as `Int`.
functionnet.unix.socket::__unix_accept
Signatureextern func __unix_accept(fd: Int, timeout_ms: Int) -> Int;
extern func __unix_accept(fd: Int, timeout_ms: Int) -> Int;
/*
@brief Binds the low-level runtime symbol `__unix_send`.
@briefBinds the low-level runtime symbol `__unix_accept`.
@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.
  • timeout_msTimeout in milliseconds; negative values usually select blocking or default timeout behavior.
@returnReturns the operation result as `Int`.
functionnet.unix.socket::__unix_send
Signatureextern func __unix_send(fd: Int, data: String, timeout_ms: Int) -> Int;
extern func __unix_send(fd: Int, data: String, timeout_ms: Int) -> Int;
/*
@brief Binds the low-level runtime symbol `__unix_recv`.
@briefBinds the low-level runtime symbol `__unix_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
  • fdOperating-system file descriptor or socket descriptor.
  • 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.unix.socket::__unix_recv
Signatureextern func __unix_recv(fd: Int, max_bytes: Int, timeout_ms: Int) -> String;
extern func __unix_recv(fd: Int, max_bytes: Int, timeout_ms: Int) -> String;
/*
@brief Binds the low-level runtime symbol `__unix_close`.
@briefBinds the low-level runtime symbol `__unix_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
  • fdOperating-system file descriptor or socket descriptor.
  • 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.unix.socket::__unix_close
Signatureextern func __unix_close(fd: Int) -> Void;
extern func __unix_close(fd: Int) -> Void;

/*
@briefBinds the low-level runtime symbol `__unix_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
  • fdOperating-system file descriptor or socket descriptor.
@returnVoid
functionnet.unix.socket::Conn.init
Signaturefunc init(self: net.unix.socket.Conn, fd: Int = -1, owns_fd: Bool = false) -> Void
    func init(self: net.unix.socket.Conn, fd: Int = -1, owns_fd: Bool = false) -> Void {
        self.fd = fd;
        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.
  • fdOperating-system file descriptor or socket descriptor.
  • owns_fdWhether the object owns the file descriptor and must close it during cleanup.
@returnVoid
functionnet.unix.socket::Conn.close
Signaturefunc close(self: net.unix.socket.Conn) -> Void
    func close(self: net.unix.socket.Conn) -> Void {
        if self.owns_fd && !self.closed && self.fd > 0 {
            _ = __unix_close(self.fd);
@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.unix.socket::Conn.dispose
Signaturefunc dispose(self: net.unix.socket.Conn) -> Void
    func dispose(self: net.unix.socket.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.unix.socket::Conn.deinit
Signaturefunc deinit(self: net.unix.socket.Conn) -> Void
    func deinit(self: net.unix.socket.Conn) -> Void {
        _ = 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.unix.socket::unix_connect
Signaturefunc unix_connect(path: String, timeout_ms: Int) -> Int
func unix_connect(path: String, timeout_ms: Int) -> Int {
    return __unix_connect(path, timeout_ms);
}
@briefProvides the system library operation `unix_connect`.
@detailsExecutes the `unix_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
  • pathFile or directory path.
  • timeout_msTimeout in milliseconds; negative values usually select blocking or default timeout behavior.
@returnReturns the operation result as `Int`.
functionnet.unix.socket::unix_listen
Signaturefunc unix_listen(path: String, backlog: Int) -> Int
func unix_listen(path: String, backlog: Int) -> Int {
    return __unix_listen(path, backlog);
}
@briefProvides the system library operation `unix_listen`.
@detailsExecutes the `unix_listen` 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
  • pathFile or directory path.
  • backlogMaximum number of pending inbound connections accepted by the listening socket.
@returnReturns the operation result as `Int`.
functionnet.unix.socket::unix_accept
Signaturefunc unix_accept(fd: Int, timeout_ms: Int) -> Int
func unix_accept(fd: Int, timeout_ms: Int) -> Int {
    return __unix_accept(fd, timeout_ms);
}
@briefProvides the system library operation `unix_accept`.
@detailsExecutes the `unix_accept` 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.
  • timeout_msTimeout in milliseconds; negative values usually select blocking or default timeout behavior.
@returnReturns the operation result as `Int`.
functionnet.unix.socket::unix_send
Signaturefunc unix_send(fd: Int, data: String, timeout_ms: Int) -> Int
func unix_send(fd: Int, data: String, timeout_ms: Int) -> Int {
    return __unix_send(fd, data, timeout_ms);
}
@briefProvides the system library operation `unix_send`.
@detailsExecutes the `unix_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
  • fdOperating-system file descriptor or socket descriptor.
  • 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.unix.socket::unix_recv
Signaturefunc unix_recv(fd: Int, max_bytes: Int, timeout_ms: Int) -> String
func unix_recv(fd: Int, max_bytes: Int, timeout_ms: Int) -> String {
    return __unix_recv(fd, max_bytes, timeout_ms);
}
@briefProvides the system library operation `unix_recv`.
@detailsExecutes the `unix_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
  • fdOperating-system file descriptor or socket descriptor.
  • 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.unix.socket::unix_close
Signaturefunc unix_close(fd: Int) -> Void
func unix_close(fd: Int) -> Void {
    _ = __unix_close(fd);
}
@briefProvides the system library operation `unix_close`.
@detailsExecutes the `unix_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
  • fdOperating-system file descriptor or socket descriptor.
@returnVoid
functionnet.unix.socket::connect
Signaturefunc connect(path: String, timeout_ms: Int = -1) -> Int, ErrCode
func connect(path: String, timeout_ms: Int = -1) -> Int, ErrCode {
    _ = net.clear_last_error();
    let fd: Int = __unix_connect(path, 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
  • pathFile or directory path.
  • 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.unix.socket::connect_conn
Signaturefunc connect_conn(path: String, timeout_ms: Int = -1) -> net.unix.socket.Conn, ErrCode
func connect_conn(path: String, timeout_ms: Int = -1) -> net.unix.socket.Conn, ErrCode {
    let fd: Int = connect(path, timeout_ms)?;
    return new net.unix.socket.Conn(fd, true), std.OK;
@briefProvides the system library operation `connect_conn`.
@detailsExecutes the `connect_conn` 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
  • pathFile or directory path.
  • timeout_msTimeout in milliseconds; negative values usually select blocking or default timeout behavior.
@returnReturns `net.unix.socket.Conn, 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.unix.socket::conn
Signaturefunc conn(fd: Int) -> net.unix.socket.Conn
func conn(fd: Int) -> net.unix.socket.Conn {
    return new net.unix.socket.Conn(fd);
}
@briefProvides the system library operation `conn`.
@detailsExecutes the `conn` 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.
@returnReturns the operation result as `net.unix.socket.Conn`.
functionnet.unix.socket::listen
Signaturefunc listen(path: String, backlog: Int = 128) -> Int, ErrCode
func listen(path: String, backlog: Int = 128) -> Int, ErrCode {
    _ = net.clear_last_error();
    let fd: Int = __unix_listen(path, backlog);
@briefCreates a listening endpoint with `listen`.
@detailsExecutes the `listen` 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
  • pathFile or directory path.
  • backlogMaximum number of pending inbound connections accepted by the listening socket.
@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.unix.socket::accept
Signaturefunc accept(fd: Int, timeout_ms: Int = -1) -> Int, ErrCode
func accept(fd: Int, timeout_ms: Int = -1) -> Int, ErrCode {
    _ = net.clear_last_error();
    let conn_fd: Int = __unix_accept(fd, timeout_ms);
@briefAccepts an incoming connection with `accept`.
@detailsExecutes the `accept` 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.
  • 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.unix.socket::set_nonblock
Signaturefunc set_nonblock(fd: Int) -> ErrCode
func set_nonblock(fd: Int) -> ErrCode {
    return net.set_nonblock(fd);
}
@briefSets state or configuration with `set_nonblock`.
@detailsExecutes the `set_nonblock` 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.
@returnReturns `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.unix.socket::send
Signaturefunc send(fd: Int, data: String, timeout_ms: Int = -1) -> Int, ErrCode
func send(fd: Int, data: String, timeout_ms: Int = -1) -> Int, ErrCode {
    _ = net.clear_last_error();
    let n: Int = __unix_send(fd, 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
  • fdOperating-system file descriptor or socket descriptor.
  • 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.unix.socket::recv
Signaturefunc recv(fd: Int, max_bytes: Int, timeout_ms: Int = -1) -> String, ErrCode
func recv(fd: Int, max_bytes: Int, timeout_ms: Int = -1) -> String, ErrCode {
    _ = net.clear_last_error();
    let s: String = __unix_recv(fd, 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
  • fdOperating-system file descriptor or socket descriptor.
  • 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.unix.socket::close
Signaturefunc close(fd: Int) -> Void
func close(fd: Int) -> Void {
    _ = __unix_close(fd);
    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
  • fdOperating-system file descriptor or socket descriptor.
@returnVoid

Variables

Class fields (var).

varnet.unix.socket::Conn.fd
TypeInt
@brief`fd` field.
@detailsStores the underlying file descriptor or socket descriptor. The field type is `Int`, and it is maintained by the constructors and methods of `Conn`.
    var fd: Int;
    /*
    @brief `closed` field.
varnet.unix.socket::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_fd` field.
varnet.unix.socket::Conn.owns_fd
TypeBool
@brief`owns_fd` field.
@detailsIndicates whether the object owns and must close the file descriptor. The field type is `Bool`, and it is maintained by the constructors and methods of `Conn`.
    var owns_fd: Bool;

    /*