Last month we started a discussion on network programming. However, in the interest of getting through an entire example of a client and a server and how they communicate, we omitted many details. This month, we’ll examine our examples more closely to gain more knowledge about network programming. Specifically, we will discuss how to get IP addresses from hostnames and hostnames from IP addresses. We will also take a look at the difference between little-endian and big-endian machines and find out why “endianness” matters in network programming.
Last month we started a discussion on network programming. However, in the interest of getting through an entire example of a client and a server and how they communicate, we omitted many details. This month, we’ll examine our examples more closely to gain more knowledge about network programming. Specifically, we will discuss how to get IP addresses from hostnames and hostnames from IP addresses. We will also take a look at the difference between little-endian and big-endian machines and find out why “endianness” matters in network programming.
Names into Numbers
In our example of a client last month, we manually specified the IP address of the server we connected to. This is impractical because it is unlikely that you will know the IP address of every server that you want to communicate with. However, you will often know the name of the machine. For example, when asked where the Linux Magazine Web site can be found, you’d probably say “http://www.linux-mag.com” instead of “http://209.81.9.15/.” Both will get you to the same place, but the domain name is easier for people to remember because it has some intrinsic meaning. An IP address is just a list of numbers that gives you no hints about what’s on the other side. In order to connect to another machine, though, you need to know its IP address.
Due to the sheer size of the Internet, mapping individual domain names to specific IP addresses is probably a job best…
Please log in to view this content.
Not Yet a Member?
Register with LinuxMagazine.com and get free access to the entire archive, including: