extDnsSession* ext_dns_listener_new ( extDnsCtx ctx,
const char *  host,
const char *  port,
extDnsSessionType  type,
extDnsListenerReady  on_ready,
axlPointer  user_data 

Creates a new extDns Listener accepting incoming sessions on the given host:port configuration and over the given protocol type (extDnsSessionType).

If user provides an on_ready callback, the listener will be notified on it, in a separated thread, once the process has finished. Check extDnsListenerReady handler documentation which is on_ready handler type.

On that notification will also be passed the host and port actually allocated. Think about using as host and port 0. These values will cause to ext_dns_listener_new to allocate the system configured hostname and a random free port. See this section for more info about on_ready parameter.

Host and port value provided to this function could be unrefered once returning from this function. The function performs a local copy for those values, that are deallocated at the appropriate moment.

Keep in mind that you can actually call several times to this function before calling to ext_dns_ctx_wait, to make your process to be able to accept sessions from several ports and host names at the same time.

While providing the port information, make sure your process will have enough rights to allocate the port provided. Usually, ports from 1 to 1024 are reserved to listener programms that runs with priviledges.

In the case the optional handler on_ready is not provided, the function will return a reference to the extDnsSession representing the listener created.

In the case the on_ready handler is provided, the function will return NULL.

Here is an example to start a ext_dns listener server:

ctxThe context where the operation will be performed.
hostThe host to listen on.
portThe port to listen on.
typeThe session type that is going to be created.
on_readyA optional callback to get a notification when ext_dns listener is ready to accept requests.
user_dataA user defined pointer to be passed in to on_ready handler.
The listener session created (represented by a extDnsSession reference). You must use ext_dns_session_is_ok to check if the server was started.

NOTE: the reference returned is only owned by the ext_dns engine. This is not the case of ext_dns_listener_new where the caller acquires automatically a reference to the session (as well as the ext_dns engine).

In this case, if your intention is to keep a reference for later operations, you must call to ext_dns_session_ref to avoid losing the reference if the system drops the session. In the same direction, you can't call to ext_dns_session_close if you don't own the reference returned by this function.