From 6676a982ff18d6a6b346f608e7ce313cfccc873e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Lo=C3=AFc=20Hoguin?= Date: Fri, 10 Apr 2015 12:42:39 +0300 Subject: Add functions await_up/{1,2,3} for sync open --- doc/src/guide/connect.asciidoc | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) (limited to 'doc') diff --git a/doc/src/guide/connect.asciidoc b/doc/src/guide/connect.asciidoc index 8de8184..f734680 100644 --- a/doc/src/guide/connect.asciidoc +++ b/doc/src/guide/connect.asciidoc @@ -52,12 +52,25 @@ form of a map. [source,erlang] {ok, ConnPid} = gun:open("example.org", 8443, #{transport=>ssl}). -=== Connection up and down messages +=== Waiting for the connection to be established When Gun successfully connects to the server, it sends a `gun_up` message with the protocol that has been selected for the connection. +Gun provides the functions `gun:await_up/{1,2,3}` that wait +for the `gun_up` message. They can optionally take a monitor +reference and/or timeout value. If no monitor is provided, +one will be created for the duration of the function call. + +.Synchronous opening of a connection + +[source,erlang] +{ok, ConnPid} = gun:open("example.org", 443), +{ok, Protocol} = gun:await_up(ConnPid). + +=== Handling connection loss + When the connection is lost, Gun will send a `gun_down` message indicating the current protocol, the reason the connection was lost and two list of stream references. -- cgit v1.2.3