cesanta/fossa — pull request #145 by mmikulicic (2014-11-27 15:58:59+00:00)
Title: Transformed ns_parse_address to be async

And transitively `ns_connect` is now async as well.
`ns_bind` is still sync although it uses internally the async `ns_parse_address`

Since `ns_connect` doesn't know whether the name resolution succeeded,
nor whether the connection is ipv4 or ipv6, it cannot create a socket
before returning. Now `ns_connect` creates an empty connection even before
opening a socket and sets a `NSF_RESOLVING` flag. If name resolution fails
or any other error where the previous implementation would have returned a
NULL, now it sets the NSF_BAD_CONNECTION flag potentially *asynchronously*.
Otherwise the connection is added to the manager and the flag cleared.

The user can detect this flag in her event handler.
Our unit tests check this flag synchronously when testing connections that
don't require name resolutions. We should document this feature so that users
know when they can assume that error propagation is sync or async.

`ns_bind` is similar to `ns_connection` but since it's always sync, it can
check whether the connection is bad before returning and will return a NULL
connection for ease of use.

DIFFBASE=#142

(DO NOT MERGE pull requests with a DIFFBASE label in the description)