Search icon CANCEL
Subscription
0
Cart icon
Your Cart (0 item)
Close icon
You have no products in your basket yet
Save more on your purchases! discount-offer-chevron-icon
Savings automatically calculated. No voucher code required.
Arrow left icon
All Products
Best Sellers
New Releases
Books
Videos
Audiobooks
Learning Hub
Newsletter Hub
Free Learning
Arrow right icon
timer SALE ENDS IN
0 Days
:
00 Hours
:
00 Minutes
:
00 Seconds
Arrow up icon
GO TO TOP
Hands-On Network Programming with C

You're reading from   Hands-On Network Programming with C Learn socket programming in C and write secure and optimized network code

Arrow left icon
Product type Paperback
Published in May 2019
Publisher Packt
ISBN-13 9781789349863
Length 478 pages
Edition 1st Edition
Languages
Tools
Concepts
Arrow right icon
Author (1):
Arrow left icon
Lewis Van Winkle Lewis Van Winkle
Author Profile Icon Lewis Van Winkle
Lewis Van Winkle
Arrow right icon
View More author details
Toc

Table of Contents (26) Chapters Close

Title Page
Copyright and Credits
Dedication
About Packt Contributors Preface 1. Introducing Networks and Protocols FREE CHAPTER 2. Getting to Grips with Socket APIs 3. An In-Depth Overview of TCP Connections 4. Establishing UDP Connections 5. Hostname Resolution and DNS 6. Building a Simple Web Client 7. Building a Simple Web Server 8. Making Your Program Send Email 9. Loading Secure Web Pages with HTTPS and OpenSSL 10. Implementing a Secure Web Server 11. Establishing SSH Connections with libssh 12. Network Monitoring and Security 13. Socket Programming Tips and Pitfalls 14. Web Programming for the Internet of Things 1. Answers to Questions 2. Setting Up Your C Compiler on Windows 3. Setting Up Your C Compiler on Linux 4. Setting Up Your C Compiler on macOS 5. Example Programs 6. Other Book You May Enjoy

Domain names

The Internet Protocol can only route packets to an IP address, not a name. So, if you try to connect to a website, such as example.com, your system must first resolve that domain name, example.com, into an IP address for the server that hosts that website.

This is done by connecting to a Domain Name System (DNS) server. You connect to a domain name server by knowing in advance its IP address. The IP address for a domain name server is usually assigned by your ISP.

Many other domain name servers are made publicly available by different organizations. Here are a few free and public DNS servers:

DNS Provider IPv4 Addresses IPv6 Addresses
Cloudflare 1.1.1.1 1.1.1.1 2606:4700:4700::1111
1.0.0.1 2606:4700:4700::1001
FreeDNS 37.235.1.174
37.235.1.177
Google Public DNS 8.8.8.8 2001:4860:4860::8888
8.8.4.4 2001:4860:4860::8844
OpenDNS 208.67.222.222 2620:0:ccc::2
208.67.220.220 2620:0:ccd::2

To resolve a hostname, your computer sends a UDP message to your domain name server and asks it for an AAAA-type record for the domain you're trying to resolve. If this record exists, an IPv6 address is returned. You can then connect to a server at that address to load the website. If no AAAA record exists, then your computer queries the server again, but asks for an A record. If this record exists, you will receive an IPv4 address for the server. In many cases, a site will publish an A record and an AAAA record that route to the same server.

It is also possible, and common, for multiple records of the same type to exist, each pointing to a different address. This is useful for redundancy in the case where multiple servers can provide the same service.

We will see a lot more about DNS queries in Chapter 5, Hostname Resolution and DNS.

Now that we have a basic understanding of IP addresses and names, let's look into detail of how IP packets are routed over the internet.

You have been reading a chapter from
Hands-On Network Programming with C
Published in: May 2019
Publisher: Packt
ISBN-13: 9781789349863
Register for a free Packt account to unlock a world of extra content!
A free Packt account unlocks extra newsletters, articles, discounted offers, and much more. Start advancing your knowledge today.
Unlock this book and the full library FREE for 7 days
Get unlimited access to 7000+ expert-authored eBooks and videos courses covering every tech area you can think of
Renews at $15.99/month. Cancel anytime
Banner background image