From 64c4668a65195283c7dbc24a677f8d3d46ac5513 Mon Sep 17 00:00:00 2001 From: Micael Karlberg Date: Thu, 2 May 2019 15:08:00 +0200 Subject: [esock|doc] Update with regard to the new select returns --- erts/doc/src/socket.xml | 30 ++++++++++++++++----- erts/doc/src/socket_usage.xml | 63 +++++++++++++++++++++++++++++++++++++------ 2 files changed, 78 insertions(+), 15 deletions(-) (limited to 'erts/doc') diff --git a/erts/doc/src/socket.xml b/erts/doc/src/socket.xml index f9dd9575f4..48e91e93a7 100644 --- a/erts/doc/src/socket.xml +++ b/erts/doc/src/socket.xml @@ -47,24 +47,40 @@ recv/3 function with Timeout set to nowait (recv(Sock, 0, nowait)) when there is actually nothing to read, it will return with - {ok, SelectInfo}. When data eventually arrives a 'select' message - will be sent to the caller: + {ok, + SelectInfo}. + When data eventually arrives a 'select' message + will be sent to the caller:

+ + + + + {'$socket', Sock, select, Info} + +

The caller can now make another call to the recv function and now expect data.

Note that all other users are locked out until the 'current user' has called the function (recv in this case).

Another message the user must be prepared for (when making asynchronous - calls) is the abort message: + calls) is the abort message:

+ + + + + {'$socket', Sock, abort, Info} + +

This message indicates that the (asynchronous) operation has been aborted. If, for instance, the socket has been - closed (by another process), Reason will be {Ref, closed}.

+ closed (by another process), Info will be {Ref, closed}.

There is currently no support for Windows.

diff --git a/erts/doc/src/socket_usage.xml b/erts/doc/src/socket_usage.xml index fcfe9b54ec..9d8141b822 100644 --- a/erts/doc/src/socket_usage.xml +++ b/erts/doc/src/socket_usage.xml @@ -54,25 +54,72 @@ recv/3 function with Timeout set to nowait (i.e. recv(Sock, 0, nowait)) when there is actually nothing to read, it will return with - {ok, SelectInfo}. When data eventually arrives a 'select message' - will be sent to the caller: + {ok, + SelectInfo}. + When data eventually arrives a 'select message' + will be sent to the caller:

+ + + + + {'$socket', Sock, select, Info} + +

The caller can then make another call to the recv function and now expect data.

-

The user must also be prepared to receive an abort message: +

The user must also be prepared to receive an abort message:

+ + + + + {'$socket', Sock, abort, Info} + +

If the operation is aborted for whatever reason (e.g. if the socket is closed "by someone else"). - The Reason part contains the abort reason (in case the socket - has been closed Reason = {Ref, closed}).

+ The Info part contains the abort reason (in this case that + the socket has been closed Info = {Ref, closed}).

Note that all other users are locked out until the 'current user' has called the function (recv in this case). So either immediately call the function or cancel.

+

The general form of the 'socket' message is:

+ + + + + {'$socket', Sock :: socket(), Tag :: atom(), Info :: term()} + +

Where the format of Info is a function of Tag:

+ + + Tag + Info value type + + + select + reference() + + + abort + {reference(), Reason :: term()} + + socket message info value type +
+

The reference() is the same as was received in the + SelectInfo.

-- cgit v1.2.3