View Source ExSCTP (ex_sctp v0.1.1)
Utilities for establishing SCTP connection and sending data over it.
Summary
Types
SCTP Payload Protocol Identifier.
SCTP stream reliability types.
ID of the SCTP stream.
Reference to mutable SCTP state.
Functions
Closes the stream with id
.
Sets stream's order and reliability parameters.
Triggers connection establishment.
Handles data received from other peer.
Handles timeout.
Initializes new SCTP connection state.
Opens a new stream with specified id
.
Produces event that needs to be handled by the library user.
Sends data over specified stream using provided ppi
.
Types
@type event() :: :none | :connected | :disconnected | {:stream_opened, stream_id()} | {:stream_closed, stream_id()} | {:data, stream_id(), ppi(), binary()} | {:transmit, [binary()]} | {:timeout, non_neg_integer() | nil}
Event obtained by calling poll/1
.
Meaning of the events:
:none
- there's no more events to handle and no actions need to be taken:connected
and:disconnected
- STCP connection has been established or closed{:stream_opened, id}
and{:stream_closed, id}
- remote side either opened or closed a stream with providedid
. This message is not created for locally opened or closed streams (by callingopen_stream/2
orclose_stream/2
){:data, id, ppi, data}
- data was received on stream withid
and is marked withppi
PPI{:transmit, [data]}
- data needs to be transmited to the other peer. You need to send the packets using appropriate means, e.g. DTLS over ICE in case of WebRTC{:timeout, val}
- informs thathandle_timeout/1
needs to be called afterval
milliseconds. Ifval
isnil
,handle_timeout/1
won't need to be called and awaiting timeouts can be canceled
@type ppi() :: non_neg_integer()
SCTP Payload Protocol Identifier.
@type reliability_type() :: :reliable | :rexmit | :timed
SCTP stream reliability types.
@type stream_id() :: 0..255
ID of the SCTP stream.
@opaque t()
Reference to mutable SCTP state.
Operate on it only using functions from this module.
Functions
Closes the stream with id
.
Calling this function will result in new events. See poll/1
for more information.
@spec configure_stream( t(), stream_id(), boolean(), reliability_type(), non_neg_integer() ) :: :ok | {:error, atom()}
Sets stream's order and reliability parameters.
@spec connect(t()) :: :ok
Triggers connection establishment.
Calling this function will result in new events. See poll/1
for more information.
Calling this function after :connected
event was received will result in an error.
Handles data received from other peer.
Calling this function will result in new events. See poll/1
for more information.
Handles timeout.
After receiving {:timeout, ms}
event from poll/1
, you must call this function after ms
milliseconds.
Calling this function will result in new events. See poll/1
for more information.
@spec new() :: t()
Initializes new SCTP connection state.
Opens a new stream with specified id
.
Calling this function will result in new events. See poll/1
for more information.
Stream IDs need to be unique. Calling this function with already existing stream id
will rsult in an error.
Produces event that needs to be handled by the library user.
New events can happen after IO is performed or timeout occurs. Related functions in
this module specify explicitly that they result in new events. If such a function is called,
the user needs to call poll/1
repeatedly and handle the events until the :none
event is received.
See event/0
to learn how to handle events.
Sends data over specified stream using provided ppi
.
Calling this function will result in new events. See poll/1
for more information.