2016-05-12 04:36:12 +08:00
|
|
|
---
|
|
|
|
title: "mg_set_protocol_dns()"
|
|
|
|
decl_name: "mg_set_protocol_dns"
|
|
|
|
symbol_kind: "func"
|
|
|
|
signature: |
|
|
|
|
void mg_set_protocol_dns(struct mg_connection *nc);
|
|
|
|
---
|
|
|
|
|
2016-07-26 00:18:19 +08:00
|
|
|
Attaches a built-in DNS event handler to the given listening connection.
|
2016-05-12 04:36:12 +08:00
|
|
|
|
2016-07-26 00:18:19 +08:00
|
|
|
The DNS event handler parses the incoming UDP packets, treating them as DNS
|
|
|
|
requests. If an incoming packet gets successfully parsed by the DNS event
|
|
|
|
handler, a user event handler will receive an `MG_DNS_REQUEST` event, with
|
2016-05-12 04:36:12 +08:00
|
|
|
`ev_data` pointing to the parsed `struct mg_dns_message`.
|
|
|
|
|
|
|
|
See
|
|
|
|
[captive_dns_server](https://github.com/cesanta/mongoose/tree/master/examples/captive_dns_server)
|
|
|
|
example on how to handle DNS request and send DNS reply.
|
|
|
|
|