No description
Find a file
Louis Pilfold 57e3331d54 Update CI
2024-08-21 12:20:26 +01:00
.github/workflows Update CI 2024-08-21 12:20:26 +01:00
src Update stdlib compat 2024-08-21 12:17:01 +01:00
test Update stdlib compat 2024-08-21 12:17:01 +01:00
.gitignore Hello, Joe! 2023-10-08 16:07:39 +01:00
CHANGELOG.md v1.1.1 2024-08-21 12:18:24 +01:00
gleam.toml v1.1.1 2024-08-21 12:18:24 +01:00
manifest.toml Update stdlib compat 2024-08-21 12:17:01 +01:00
README.md 🍺 2024-01-09 16:10:33 +00:00

mug 🍺

Package Version Hex Docs

A TCP client for Gleam!

gleam add mug
import mug

pub fn main() {
  // Form a connection to a TCP server
  let assert Ok(socket) =
    mug.new("erlang-the-movie.example.com", port: 12345)
    |> mug.timeout(milliseconds: 500)
    |> mug.connect()

  // Send a packet to the server
  let assert Ok(Nil) = mug.send(socket, <<"Hello, Joe!\n":utf8>>)

  // Receive a packet back
  let assert Ok(packet) = mug.receive(socket, timeout_milliseconds: 100)
  
  packet
  // -> <<"Hello, Mike!":utf8>>
}

It also includes support for receiving packages as Erlang messages, enabling TCP sockets to be used within OTP actors.

Documentation can be found at https://hexdocs.pm/mug.