万本电子书0元读

万本电子书0元读

顶部广告

Hands-On Network Programming with C电子书

售       价:¥

4人正在读 | 0人评论 6.2

作       者:Lewis Van Winkle

出  版  社:Packt Publishing

出版时间:2019-05-13

字       数:54.4万

所属分类: 进口书 > 外文原版书 > 电脑/网络

温馨提示:数字商品不支持退换货,不提供源文件,不支持导出打印

为你推荐

  • 读书简介
  • 目录
  • 累计评论(0条)
  • 读书简介
  • 目录
  • 累计评论(0条)
A comprehensive guide to programming with network sockets, implementing Internet protocols, designing IoT devices, and much more with C Key Features * Leverage your C or C++ programming skills to build powerful network applications * Get to grips with a variety of network protocols that allow you to load web pages, send emails, and do much more * Write portable network code for operating systems such as Windows, Linux, and macOS Book Description Network programming, a challenging topic in C, is made easy to understand with a careful exposition of socket programming APIs. This book gets you started with modern network programming in C and the right use of relevant operating system APIs. This book covers core concepts, such as hostname resolution with DNS, that are crucial to the functioning of the modern web. You’ll delve into the fundamental network protocols, TCP and UDP. Essential techniques for networking paradigms such as client-server and peer-to-peer models are explained with the help of practical examples. You’ll also study HTTP and HTTPS (the protocols responsible for web pages) from both the client and server perspective. To keep up with current trends, you’ll apply the concepts covered in this book to gain insights into web programming for IoT. You’ll even get to grips with network monitoring and implementing security best practices. By the end of this book, you’ll have experience of working with client-server applications, and be able to implement new network programs in C. The code in this book is compatible with the older C99 version as well as the latest C18 and C++17 standards. Special consideration is given to writing robust, reliable, and secure code that is portable across operating systems, including Winsock sockets for Windows and POSIX sockets for Linux and macOS. What you will learn * Uncover cross-platform socket programming APIs * Implement techniques for supporting IPv4 and IPv6 * Understand how TCP and UDP connections work over IP * Discover how hostname resolution and DNS work * Interface with web APIs using HTTP and HTTPS * Acquire hands-on experience with Simple Mail Transfer Protocol (SMTP) * Apply network programming to the Internet of Things (IoT) Who this book is for If you're a developer or a system administrator who wants to enter the world of network programming, this book is for you. Basic knowledge of C programming is assumed.
目录展开

Dedication

About Packt

Why subscribe?

Packt.com

Contributors

About the author

About the reviewer

Packt is searching for authors like you

Preface

Who this book is for

What this book covers

To get the most out of this book

Download the example code files

Download the color images

Conventions used

Get in touch

Reviews

Section 1 - Getting Started with Network Programming

Introducing Networks and Protocols

Technical requirements

The internet and C

OSI layer model

TCP/IP layer model

Data encapsulation

Internet Protocol

What is an address?

Domain names

Internet routing

Local networks and address translation

Subnetting and CIDR

Multicast, broadcast, and anycast

Port numbers

Clients and servers

Putting it together

What's your address?

Listing network adapters from C

Listing network adapters on Windows

Listing network adapters on Linux and macOS

Summary

Questions

Getting to Grips with Socket APIs

Technical requirements

What are sockets?

Socket setup

Two types of sockets

Socket functions

Anatomy of a socket program

TCP program flow

UDP program flow

Berkeley sockets versus Winsock sockets

Header files

Socket data type

Invalid sockets

Closing sockets

Error handling

Our first program

A motivating example

Making it networked

Working with IPv6

Supporting both IPv4 and IPv6

Networking with inetd

Summary

Questions

An In-Depth Overview of TCP Connections

Technical requirements

Multiplexing TCP connections

Polling non-blocking sockets

Forking and multithreading

The select() function

Synchronous multiplexing with select()

select() timeout

Iterating through an fd_set

select() on non-sockets

A TCP client

TCP client code

A TCP server

TCP server code

Building a chat room

Blocking on send()

TCP is a stream protocol

Summary

Questions

Establishing UDP Connections

Technical requirements

How UDP sockets differ

UDP client methods

UDP server methods

A first UDP client/server

A simple UDP server

A simple UDP client

A UDP server

Summary

Questions

Hostname Resolution and DNS

Technical requirements

How hostname resolution works

DNS record types

DNS security

Name/address translation functions

Using getaddrinfo()

Using getnameinfo()

Alternative functions

IP lookup example program

The DNS protocol

DNS message format

DNS message header format

Question format

Answer format

Endianness

A simple DNS query

A DNS query program

Printing a DNS message name

Printing a DNS message

Sending the query

Summary

Questions

Further reading

Section 2 - An Overview of Application Layer Protocols

Building a Simple Web Client

Technical requirements

The HTTP protocol

HTTP request types

HTTP request format

HTTP response format

HTTP response codes

Response body length

What's in a URL

Parsing a URL

Implementing a web client

HTTP POST requests

Encoding form data

File uploads

Summary

Questions

Further reading

Building a Simple Web Server

Technical requirements

The HTTP server

The server architecture

Content types

Returning Content-Type from a filename

Creating the server socket

Multiple connections buffering

get_client()

drop_client()

get_client_address()

wait_on_clients()

send_400()

send_404()

serve_resource()

The main loop

Security and robustness

Open source servers

Summary

Questions

Further reading

Making Your Program Send Email

Technical requirements

Email servers

SMTP security

Finding an email server

SMTP dialog

The format of an email

A simple SMTP client program

Enhanced emails

Email file attachments

Spam-blocking pitfalls

Summary

Questions

Further reading

Section 3 - Understanding Encrypted Protocols and OpenSSL

Loading Secure Web Pages with HTTPS and OpenSSL

Technical requirements

HTTPS overview

Encryption basics

Symmetric ciphers

Asymmetric ciphers

How TLS uses ciphers

The TLS protocol

Certificates

Server name identification

OpenSSL

Encrypted sockets with OpenSSL

Certificates

A simple HTTPS client

Other examples

Summary

Questions

Further reading

Implementing a Secure Web Server

Technical requirements

HTTPS and OpenSSL summary

Certificates

Self-signed certificates with OpenSSL

HTTPS server with OpenSSL

Time server example

A full HTTPS server

HTTPS server challenges

OpenSSL alternatives

Alternatives to TLS

Summary

Questions

Further reading

Establishing SSH Connections with libssh

Technical requirements

The SSH protocol

libssh

Testing out libssh

Establishing a connection

SSH authentication

Server authentication

Client authentication

Executing a remote command

Downloading a file

Summary

Questions

Further reading

Section 4 - Odds and Ends

Network Monitoring and Security

Technical requirements

The purpose of network monitoring

Testing reachability

Checking a route

How traceroute works

Raw sockets

Checking local connections

Snooping on connections

Deep packet inspection

Capturing all network traffic

Network security

Application security and safety

Network-testing etiquette

Summary

Questions

Further reading

Socket Programming Tips and Pitfalls

Technical requirements

Error handling

Obtaining error descriptions

TCP socket tips

Timeout on connect()

TCP flow control and avoiding deadlock

Congestion control

The Nagle algorithm

Delayed acknowledgment

Connection tear-down

The shutdown() function

Preventing address-in-use errors

Sending to a disconnected peer

Socket's local address

Multiplexing with a large number of sockets

Summary

Questions

Web Programming for the Internet of Things

Technical requirements

What is the IoT?

Connectivity options

Wi-Fi

Ethernet

Cellular

Bluetooth

IEEE 802.15.4 WPANs

Hardware choices

Single-board computers

Microcontrollers

FPGAs

External transceivers and modems

IoT protocols

Firmware updates

Ethics of IoT

Privacy and data collection

End-of-life planning

Security

Summary

Questions

Answers to Questions

Chapter 1, Introducing Networks and Protocols

Chapter 2, Getting to Grips with Socket APIs

Chapter 3, An In-Depth Overview of TCP Connections

Chapter 4, Establishing UDP Connections

Chapter 5, Hostname Resolution and DNS

Chapter 6, Building a Simple Web Client

Chapter 7, Building a Simple Web Server

Chapter 8, Making Your Program Send Email

Chapter 9, Loading Secure Web Pages with HTTPS and OpenSSL

Chapter 10, Implementing a Secure Web Server

Chapter 11, Establishing SSH Connections with libssh

Chapter 12, Network Monitoring and Security

Chapter 13, Socket Programming Tips and Pitfalls

Chapter 14, Web Programming for the Internet of Things

Setting Up Your C Compiler on Windows

Installing MinGW GCC

Installing Git

Installing OpenSSL

Installing libssh

Alternatives

Setting Up Your C Compiler on Linux

Installing GCC

Installing Git

Installing OpenSSL

Installing libssh

Setting Up Your C Compiler on macOS

Installing Homebrew and the C compiler

Installing OpenSSL

Installing libssh

Example Programs

Code license

Code included with this book

Chapter 1 – Introducing Networks and Protocols

Chapter 2 – Getting to Grips with Socket APIs

Chapter 3 – An In-Depth Overview of TCP Connections

Chapter 4 – Establishing UDP Connections

Chapter 5 – Hostname Resolution and DNS

Chapter 6 – Building a Simple Web Client

Chapter 7 – Building a Simple Web Server

Chapter 8 – Making Your Program Send Email

Chapter 9 – Loading Secure Web Pages with HTTPS and OpenSSL

Chapter 10 – Implementing a Secure Web Server

Chapter 11 – Establishing SSH Connections with libssh

Chapter 12 – Network Monitoring and Security

Chapter 13 – Socket Programming Tips and Pitfalls

Chapter 14 – Web Programming for the Internet of Things

Other Book You May Enjoy

Leave a review - let other readers know what you think

累计评论(0条) 0个书友正在讨论这本书 发表评论

发表评论

发表评论,分享你的想法吧!

买过这本书的人还买过

读了这本书的人还在读

回顶部