network - Palamecia/mint GitHub Wiki

Module network

Description

This module provides the core abstractions used to interact with a network.

It is organized around three main layers:

  • The Network.Endpoint abstraction describes a network peer address and the protocol-specific information required to reach it.
  • The Network.Socket abstraction represents a transport endpoint for a specific protocol family such as TCP or UDP.
  • The Network.Channel and Network.EventChannel classes expose message-based communication over a socket. The synchronous channel is suitable for direct operation, while the event channel integrates with the runtime scheduler for asynchronous I/O.

The module also provides protocol-specific client and server classes for layers 5 to 7 of the OSI model, such as HTTP and JSON-RPC, together with polling and scheduler integration helpers.

load network.poller
load network.sockets.tcp
load network.endpoints.ip
load network.protocols.http.client

if let client = Network.Http.Client(Network.TcpSocket()) {
    client.onMessage = def (self, channel) {
        sendToBrowser(self.read())
    }

    client.connect(Network.IpEndpoint(serverHost, serverPort))

    let poller = Network.Poller()
    poller.watch(client)
    while running {
        poller.poll()
    }

    client.close()
}

Packages

Enums

Classes

Constants

Functions