Commit c5b8e55e authored by Evelyn's avatar Evelyn Committed by GitHub

Update mg_connect_opt.md

parent 559874fc
......@@ -8,11 +8,11 @@ signature: |
struct mg_connect_opts opts);
---
Connect to a remote host.
Connects to a remote host.
`address` format is `[PROTO://]HOST:PORT`. `PROTO` could be `tcp` or `udp`.
The `address` format is `[PROTO://]HOST:PORT`. `PROTO` could be `tcp` or `udp`.
`HOST` could be an IP address,
IPv6 address (if Mongoose is compiled with `-DMG_ENABLE_IPV6`), or a host
IPv6 address (if Mongoose is compiled with `-DMG_ENABLE_IPV6`) or a host
name. If `HOST` is a name, Mongoose will resolve it asynchronously. Examples
of valid addresses: `google.com:80`, `udp://1.2.3.4:53`, `10.0.0.1:443`,
`[::1]:80`
......@@ -20,18 +20,18 @@ of valid addresses: `google.com:80`, `udp://1.2.3.4:53`, `10.0.0.1:443`,
See the `mg_connect_opts` structure for a description of the optional
parameters.
Returns a new outbound connection, or `NULL` on error.
Returns a new outbound connection or `NULL` on error.
NOTE: Connection remains owned by the manager, do not free().
NOTE: The connection remains owned by the manager, do not free().
NOTE: To enable IPv6 addresses, `-DMG_ENABLE_IPV6` should be specified
NOTE: To enable IPv6 addresses `-DMG_ENABLE_IPV6` should be specified
in the compilation flags.
NOTE: New connection will receive `MG_EV_CONNECT` as it's first event
which will report connect success status.
If asynchronous resolution fail, or `connect()` syscall fail for whatever
NOTE: The new connection will receive `MG_EV_CONNECT` as its first event
which will report the connect success status.
If the asynchronous resolution fails or the `connect()` syscall fails for whatever
reason (e.g. with `ECONNREFUSED` or `ENETUNREACH`), then `MG_EV_CONNECT`
event report failure. Code example below:
event will report failure. Code example below:
```c
static void ev_handler(struct mg_connection *nc, int ev, void *ev_data) {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment