Resolving names to addresses with libnet
In this recipe, we learn how to resolve DNS names (such as www.packtpub.com) to IP addresses using libnet. This recipe will introduce libnet functions that will resolve the address from the DNS name and display the address. It will also introduce the libnet_init()
and libnet_destroy()
functions.
The libnet_init()
function initializes and returns a libnet context. This context is the center of everything that libnet does. A libnet context should be initialized prior to using any of the libnet functions. The context should also be destroyed, using the libnet_destroy()
function, once it is no longer needed.
Getting ready
Prior to running the examples in the chapter, we will need to download and install libnet (see the Installing libnet recipe of this chapter). You will also need to add libnet to your project (see the Adding libnet to your project recipe of this chapter).
Don't forget that if we wish to run our project within Xcode, we will need to change...