diff options
author | Micael Karlberg <[email protected]> | 2019-02-21 11:52:50 +0100 |
---|---|---|
committer | Micael Karlberg <[email protected]> | 2019-02-22 19:45:54 +0100 |
commit | b71c341212fa1ff07eac914e07bc57303c2c4385 (patch) | |
tree | 239ad520425edb4eb8ead7c0594db3fceee999ee | |
parent | 24c82c328bf9ee278f67ba05e4f6c89dd1333a59 (diff) | |
download | otp-b71c341212fa1ff07eac914e07bc57303c2c4385.tar.gz otp-b71c341212fa1ff07eac914e07bc57303c2c4385.tar.bz2 otp-b71c341212fa1ff07eac914e07bc57303c2c4385.zip |
[socket|doc] Improve the examples
-rw-r--r-- | erts/doc/src/socket.xml | 17 |
1 files changed, 8 insertions, 9 deletions
diff --git a/erts/doc/src/socket.xml b/erts/doc/src/socket.xml index 795df0d238..caf7058b34 100644 --- a/erts/doc/src/socket.xml +++ b/erts/doc/src/socket.xml @@ -614,14 +614,13 @@ <title>Examples</title> <marker id="examples"></marker> <code type="none"> -client(Addr, Port) -> +client(Addr, SAddr, SPort) -> {ok, Sock} = socket:open(inet, stream, tcp), - ok = socket:bind(Sock, #{family => inet, - port => 0, - addr => any}), + {ok, _} = socket:bind(Sock, #{family => inet, + addr => Addr}), ok = socket:connect(Sock, #{family => inet, - addr => Addr, - port => Port}), + addr => SAddr, + port => SPort}), Msg = list_to_binary("hello"), ok = socket:send(Sock, Msg), ok = socket:shutdown(Sock, write), @@ -630,9 +629,9 @@ client(Addr, Port) -> server(Addr, Port) -> {ok, LSock} = socket:open(inet, stream, tcp), - ok = socket:bind(LSock, #{family => inet, - port => Port, - addr => Addr}), + {ok, _} = socket:bind(LSock, #{family => inet, + port => Port, + addr => Addr}), ok = socket:listen(LSock), {ok, Sock} = socket:accept(LSock), {ok, Msg} = socket:recv(Sock), |