Package Network - Palamecia/mint GitHub Wiki

Package Network

Description

The Network package provides the abstractions and transports used to build networked applications in Mint.

It is organized around three main layers:

  • The Network.Endpoint abstraction describes peer addresses and the protocol-specific information needed to reach them.
  • 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 appropriate for direct use, while the event channel integrates with the runtime scheduler for asynchronous I/O.

The package also provides protocol-specific client and server classes for layers 5 to 7 of the OSI model, together with polling and runtime 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

⚠️ **GitHub.com Fallback** ⚠️