node_socket_client

Bindings to Node’s TCP socket client.

Package Version Hex Docs

gleam add node_socket_client@1
import node_socket_client.{DataEvent, CloseEvent, ErrorEvent} as socket

pub fn main() {
  socket.connect("localhost", 3000, 0, fn(count, _socket, event) {
    case event {
      DataEvent(data) -> io.println("Got data: " <> data)
      ErrorEvent(error) -> io.println("Got error: " <> error)
      CloseEvent(had_error: True) -> io.println("Closed with error")
      CloseEvent(had_error: False) -> io.println("Closed")
      _other_event -> Nil
    }
    count + 1
  })
}

Further documentation can be found at https://hexdocs.pm/node_socket_client.

Search Document