Sha256: 4760fcd70714242b9a33497dfc9e02b612e24b7a28b264948979490913b0c0d4

Contents?: true

Size: 573 Bytes

Versions: 14

Compression:

Stored size: 573 Bytes

Contents

-module(bertio).

-export([open_port/2, port_close/1]).
-export([send/2, recv/1, recv/2]).

open_port(PortName, PortOptions) ->
  erlang:open_port(PortName, [{packet, 4}, nouse_stdio, binary|PortOptions]).

send(Port, BERT) ->
  BERP = bert:encode(BERT),
  erlang:port_command(Port, BERP).

recv(Port) ->
  recv(Port, 1000).

recv(Port, Timeout) ->
  receive
  {Port, {data, BERP}} ->
    {bert, bert:decode(BERP)};
  {Port, Other} ->
    {Port, Other}
  after Timeout ->
    erlang:error(timeout)
  end.

port_close(Port) ->
  send(Port, stop),
  erlang:port_close(Port).

Version data entries

14 entries across 14 versions & 1 rubygems

Version Path
capricorn-2.0.11 erlang/lib/bertio/src/bertio.erl
capricorn-2.0.10 erlang/lib/bertio/src/bertio.erl
capricorn-2.0.9 erlang/lib/bertio/src/bertio.erl
capricorn-2.0.8 erlang/lib/bertio/src/bertio.erl
capricorn-2.0.7 erlang/lib/bertio/src/bertio.erl
capricorn-2.0.6 erlang/lib/bertio/src/bertio.erl
capricorn-2.0.5 erlang/lib/bertio/src/bertio.erl
capricorn-2.0.4 erlang/lib/bertio/src/bertio.erl
capricorn-2.0.3 erlang/lib/bertio/src/bertio.erl
capricorn-2.0.3.pre2 erlang/lib/bertio/src/bertio.erl
capricorn-2.0.3.pre erlang/lib/bertio/src/bertio.erl
capricorn-2.0.2 erlang/lib/bertio/src/bertio.erl
capricorn-2.0.1 erlang/lib/bertio/src/bertio.erl
capricorn-2.0.0 erlang/lib/bertio/src/bertio.erl