It is the noon hour and the battle of your morning meetings and issues has been subdued for the moment. The silence of the cubicles is maligned by the rattle of your brown-bag lunch. Your browser springs to life, after an entire morning of standing by in a minimized state. You tap out a few keystrokes http://184.108.40.206 and press ENTER. Huh?
What's wrong with this picture? It was the IP number 220.127.116.11, wasn't it? After all, what site is that? You likely know this as the site www.lwn.net instead, where you get your Linux Weekly News (at least at the time of this writing).
Your associate at work won't ask you to ftp some source code from ftp site 18.104.22.168, will he? Instead, he'll ask you to ftp from sunsite.unc.edu. As you know, IP numbers are simply not easy to remember. In this post I will teach you about
- How to determine your local hostname
- How to resolve a hostname into an IP number
- How to resolve an IP number into a hostname
- Using sethostent
- Using endhostent
Read all links above, now you will be able to use hostnames or IP numbers in your client and server programs.