aboutsummaryrefslogtreecommitdiffstats
path: root/doc/src/manual/gun.open.asciidoc
diff options
context:
space:
mode:
authorLoïc Hoguin <[email protected]>2018-06-02 22:44:16 +0200
committerLoïc Hoguin <[email protected]>2018-06-02 22:44:16 +0200
commit5b810c924da242632a04a2c44772cb892aa1b7c0 (patch)
treee9ee81bd3b6aea1f9665914b8858edad377c24c7 /doc/src/manual/gun.open.asciidoc
parent04b41c3cf70aba88c1dd76e4e86c39458d817219 (diff)
downloadgun-5b810c924da242632a04a2c44772cb892aa1b7c0.tar.gz
gun-5b810c924da242632a04a2c44772cb892aa1b7c0.tar.bz2
gun-5b810c924da242632a04a2c44772cb892aa1b7c0.zip
Revamp the manual, one page per function/message
Diffstat (limited to 'doc/src/manual/gun.open.asciidoc')
-rw-r--r--doc/src/manual/gun.open.asciidoc72
1 files changed, 72 insertions, 0 deletions
diff --git a/doc/src/manual/gun.open.asciidoc b/doc/src/manual/gun.open.asciidoc
new file mode 100644
index 0000000..2e6c8b9
--- /dev/null
+++ b/doc/src/manual/gun.open.asciidoc
@@ -0,0 +1,72 @@
+= gun:open(3)
+
+== Name
+
+gun:open - Open a connection to the given host and port
+
+== Description
+
+[source,erlang]
+----
+open(Host, Port) -> open(Host, Port, #{})
+open(Host, Port, Opts) -> {ok, pid()} | {error, any()}
+
+Host :: inet:hostname() | inet:ip_address()
+Port :: inet:port_number()
+Opts :: gun:opts()
+----
+
+Open a connection to the given host and port.
+
+== Arguments
+
+Host::
+
+Host or IP address to connect to.
+
+Port::
+
+Port to connect to.
+
+Opts::
+
+Options for this connection.
+
+== Return value
+
+The pid of the newly created Gun process is returned.
+Note that this does not indicate that the connection
+has been successfully opened; the link:man:gun_up(3)[gun_up(3)]
+message will be sent for that.
+
+== Changelog
+
+* *1.0*: Function introduced.
+
+== Examples
+
+.Connect to a server
+[source,erlang]
+----
+{ok, ConnPid} = gun:open("example.org", 443).
+----
+
+.Connect to a server with custom options
+[source,erlang]
+----
+{ok, ConnPid} = gun:open("example.org", 443,
+ #{protocols => [http2]}).
+----
+
+.Connect to a server using its IP address
+[source,erlang]
+----
+{ok, ConnPid} = gun:open({127,0,0,1}, 443).
+----
+
+== See also
+
+link:man:gun(3)[gun(3)],
+link:man:gun:open_unix(3)[gun:open_unix(3)],
+link:man:gun:await_up(3)[gun:await_up(3)],
+link:man:gun_up(3)[gun_up(3)]