Skip to content

Commit 28743c0

Browse files
committed
kernel: gen_sctp: document the {sctp_error, ...} message
The `{sctp_error, ...}` message is not documented, but it does exist. The logic that generates both `{sctp, ...}` and `{sctp_error, ...}` messages resides in inet_drv.c, specifically in packet_binary_message() and sctp_parse_async_event(). Within sctp_parse_async_event(), an error is indicated by replacing the initial `sctp` atom with `sctp_error`. The following SCTP events are currently reported as errors: * SCTP_SEND_FAILED (becomes #sctp_send_failed{}), * SCTP_REMOTE_ERROR (becomes #sctp_remote_error{}), * SCTP_PARTIAL_DELIVERY_EVENT (becomes #sctp_pdapi_event{}). Document this and update the example code to print errors.
1 parent cf01a8c commit 28743c0

File tree

1 file changed

+13
-0
lines changed

1 file changed

+13
-0
lines changed

lib/kernel/src/gen_sctp.erl

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -613,6 +613,11 @@ client_loop(S, Peer1, Port1, AssocId1, Peer2, Port2, AssocId2) ->
613613
client_loop(S, Peer1, Port1, AssocId1,
614614
Peer2, Port2, AssocId2);
615615

616+
{sctp_error, S, _Peer, _Port, {_Anc, Error}} ->
617+
io:format("SCTP error: ~p~n", [Error]),
618+
client_loop(S, Peer1, Port1, AssocId1,
619+
Peer2, Port2, AssocId2);
620+
616621
Other ->
617622
io:format("Other ~p~n", [Other]),
618623
client_loop(S, Peer1, Port1, AssocId1,
@@ -818,6 +823,14 @@ received data is delivered to the controlling process as messages:
818823
{sctp, Socket, FromIP, FromPort, {AncData, Data}}
819824
```
820825

826+
Error-related events - such as `#sctp_send_failed{}`, `#sctp_pdapi_event{}`,
827+
and `#sctp_remote_error{}` - are also delivered to the controlling process
828+
as messages, but use a different tuple tag:
829+
830+
```erlang
831+
{sctp_error, Socket, FromIP, FromPort, {AncData, Data}}
832+
```
833+
821834
See [`recv/1,2`](`recv/1`) for a description of the message fields.
822835

823836
> #### Note {: .info }

0 commit comments

Comments
 (0)