Skip to content

EInterface

[Source]

A C node: this side of a connection to a running Erlang/Elixir node.

One EInterface owns one connection. connect creates the node on first use, so the node name is available before it is connected, and disconnect closes the connection without throwing the node away. dispose releases both, and an interface that has been disposed stays inert.

class ref EInterface

Constructors

create

[Source]

new ref create(
  this_nodename': String val,
  cookie': String val,
  creation': U32 val = 0)
: EInterface ref^

Parameters

Returns


relay

[Source]

A connection that arrived on another interface's listening socket.

It shares that interface's node, and holds the node until both are done with it, so neither order of disposal leaves the other with a freed node.

new ref relay(
  node: Pointer[None val] ref,
  connection: Connection,
  peer: String val = "")
: EInterface ref^

Parameters

Returns


Public Functions

connected

[Source]

fun box connected()
: Bool val

Returns


connect

[Source]

Connects to a node, blocking until it answers.

The C library keeps process wide state, and this holds the lock over it while it waits, so use connect_with_timeout when the other node may not answer.

fun ref connect(
  nodename: String val)
: ConnectionStatus

Parameters

Returns


connect_with_timeout

[Source]

Connects to a node, giving up after timeout_ms milliseconds.

fun ref connect_with_timeout(
  nodename: String val,
  timeout_ms: U32 val)
: ConnectionStatus

Parameters

Returns


disconnect

[Source]

Closes the connection. The node itself stays usable for a new one.

fun ref disconnect()
: None val

Returns


publish

[Source]

Registers this node's name with epmd and listens for connections on port, or on a port of the system's choosing when it is zero, so that other nodes can connect to this one.

The name is withdrawn with unpublish, or when the process ends.

fun ref publish(
  port: U32 val)
: PublishResult

Parameters

  • port: U32 val

Returns


published_port

[Source]

The port the listening socket took, and zero before publish.

fun box published_port()
: U32 val

Returns


unpublish

[Source]

Closes the listening socket, so the node cannot be called any more.

The name itself is epmd's: it holds it for as long as the session the C library keeps open for it, which ends with the process, so a node of the same name cannot be published again in this process.

fun ref unpublish()
: None val

Returns


accept

[Source]

Waits for another node to connect to this one.

fun ref accept()
: AcceptResult

Returns


accept_with_timeout

[Source]

Waits up to timeout_ms for another node to connect; zero waits forever and is the same as accept.

fun ref accept_with_timeout(
  timeout_ms: U32 val)
: AcceptResult

Parameters

  • timeout_ms: U32 val

Returns


peer_nodename

[Source]

The node at the other end of an accepted connection, and empty for a connection this interface opened itself.

fun box peer_nodename()
: String val

Returns


dispose

[Source]

Releases the connection and the node now, not when the collector runs. A disposed interface does nothing on any later call.

A published node stops listening here, so nobody can call it any more.

fun ref dispose()
: None val

Returns


receive

[Source]

Waits for a message.

fun ref receive()
: ReceiveResult

Returns


receive_with_timeout

[Source]

Waits for a message, giving up after timeout_ms; zero means wait forever and is the same as receive.

The time is a deadline: the polls the other side sends on a quiet connection do not start it again. Those polls are answered here, which is what keeps the connection alive, so a connection nobody reads for longer than the other node's net_ticktime is dropped by that node.

fun ref receive_with_timeout(
  timeout_ms: U32 val)
: ReceiveResult

Parameters

  • timeout_ms: U32 val

Returns


send_to

[Source]

Sends an encoded message to a process.

fun ref send_to(
  to: ErlangPid val,
  what: EMessage ref,
  timeout_ms: U32 val)
: SendResult

Parameters

Returns


send_to_registered

[Source]

Sends an encoded message to a process registered under a name.

fun ref send_to_registered(
  server_name: String val,
  what: EMessage ref,
  timeout_ms: U32 val)
: SendResult

Parameters

Returns


self_pid

[Source]

This node's own pid, as the remote node sees it.

fun ref self_pid()
: ErlangPid val ?

Returns


this_nodename

[Source]

fun ref this_nodename()
: String val

Returns


this_hostname

[Source]

fun ref this_hostname()
: String val

Returns


this_alivename

[Source]

fun ref this_alivename()
: String val

Returns


set_tracelevel

[Source]

fun box set_tracelevel(
  level: I32 val)
: None val

Parameters

  • level: I32 val

Returns


get_tracelevel

[Source]

fun box get_tracelevel()
: I32 val

Returns


set_compat_rel

[Source]

fun box set_compat_rel(
  rel: U32 val)
: None val

Parameters

Returns


last_error

[Source]

The reason the last call into the C layer failed, as far as it knows.

fun box last_error()
: String val

Returns