this example sets up dictionary that dumbly maps few domains to ipv addresses it is followed by two functions that extract information from binary dns query packet and construct the response we won' be discussing theseif you want to know more about dns read rfc ("request for comment"the format for defining most internet protocols and you can test this service by running the following command in another terminalnslookup -port= facebook com localhost let' get on with the entree asyncio networking revolves around the intimately linked concepts of transports and protocols protocol is class that has specific methods that are called when relevant events happen since dns runs on top of udp (user datagram protocol)we build our protocol class as subclass of datagramprotocol this class has variety of events that it can respond towe are specifically interested in the initial connection occurring (solely so we can store the transport for future useand the datagram_received event for dnseach received datagram must be parsed and responded toat which point the interaction is over sowhen datagram is receivedwe process the packetlook up the ipand construct response using the functions we aren' talking about (they're black sheep in the familythen we instruct the underlying transport to send the resulting packet back to the requesting client using its sendto method the transport essentially represents communication stream in this caseit abstracts away all the fuss of sending and receiving data on udp socket on an event loop there are similar transports for interacting with tcp sockets and subprocessesfor example the udp transport is constructed by calling the loop' create_datagram_endpoint coroutine this constructs the appropriate udp socket and starts listening on it we pass it the address that the socket needs to listen onand importantlythe protocol class we created so that the transport knows what to call when it receives data since the process of initializing socket takes non-trivial amount of time and would block the event loopthe create_datagram_endpoint function is coroutine in our examplewe don' really need to do anything while we wait for this initializationso we wrap the call in loop run_until_complete the event loop takes care of managing the futureand when it' completeit returns tuple of two valuesthe newly initialized transport and the protocol object that was constructed from the class we passed in