Home Page Icon
Home Page
Table of Contents for
Part II: Socket-level Programming
Close
Part II: Socket-level Programming
by
Network Programming with Go
Acknowledgments
Introduction
Who This Book Is For
Installing Go
Recommended Development Environments
What’s in This Book
Part I: Network Architecture
Chapter 1: An Overview of Networked Systems
Choosing a Network Topology
Bandwidth vs. Latency
The Open Systems Interconnection Reference Model
The Hierarchal Layers of the OSI Reference Model
Sending Traffic by Using Data Encapsulation
The TCP/IP Model
The Application Layer
The Transport Layer
The Internet Layer
The Link Layer
What You’ve Learned
Chapter 2: Resource Location and Traffic Routing
The Internet Protocol
IPv4 Addressing
Network and Host IDs
Subdividing IPv4 Addresses into Subnets
Ports and Socket Addresses
Network Address Translation
Unicasting, Multicasting, and Broadcasting
Resolving the MAC Address to a Physical Network Connection
IPv6 Addressing
Writing IPv6 Addresses
IPv6 Address Categories
Advantages of IPv6 over IPv4
The Internet Control Message Protocol
Internet Traffic Routing
Routing Protocols
The Border Gateway Protocol
Name and Address Resolution
Domain Name Resource Records
Multicast DNS
Privacy and Security Considerations of DNS Queries
What You’ve Learned
Part II: Socket-level Programming
Chapter 3: Reliable TCP Data Streams
What Makes TCP Reliable?
Working with TCP Sessions
Establishing a Session with the TCP Handshake
Acknowledging Receipt of Packets by Using Their Sequence Numbers
Receive Buffers and Window Sizes
Gracefully Terminating TCP Sessions
Handling Less Graceful Terminations
Establishing a TCP Connection by Using Go’s Standard Library
Binding, Listening for, and Accepting Connections
Establishing a Connection with a Server
Implementing Deadlines
What You’ve Learned
Chapter 4: Sending TCP Data
Using the net.Conn Interface
Sending and Receiving Data
Reading Data into a Fixed Buffer
Delimited Reading by Using a Scanner
Dynamically Allocating the Buffer Size
Handling Errors While Reading and Writing Data
Creating Robust Network Applications by Using the io Package
Proxying Data Between Connections
Monitoring a Network Connection
Pinging a Host in ICMP-Filtered Environments
Exploring Go’s TCPConn Object
Controlling Keepalive Messages
Handling Pending Data on Close
Overriding Default Receive and Send Buffers
Solving Common Go TCP Network Problems
Zero Window Errors
Sockets Stuck in the CLOSE_WAIT State
What You’ve Learned
Chapter 5: Unreliable UDP Communication
Using UDP: Simple and Unreliable
Sending and Receiving UDP Data
Using a UDP Echo Server
Receiving Data from the Echo Server
Every UDP Connection Is a Listener
Using net.Conn in UDP
Avoiding Fragmentation
What You’ve Learned
Chapter 6: Ensuring UDP Reliability
Reliable File Transfers Using TFTP
TFTP Types
Read Requests
Data Packets
Acknowledgments
Handling Errors
The TFTP Server
Writing the Server Code
Handling Read Requests
Starting the Server
Downloading Files over UDP
What You’ve Learned
Chapter 7: Unix Domain Sockets
What Are Unix Domain Sockets?
Binding to Unix Domain Socket Files
Changing a Socket File’s Ownership and Permissions
Understanding Unix Domain Socket Types
Writing a Service That Authenticates Clients
Requesting Peer Credentials
Writing the Service
Testing the Service with Netcat
What You’ve Learned
Part III: Application-level Programming
Chapter 8: Writing HTTP Clients
Understanding the Basics of HTTP
Uniform Resource Locators
Client Resource Requests
Server Responses
From Request to Rendered Page
Retrieving Web Resources in Go
Using Go’s Default HTTP Client
Closing the Response Body
Implementing Time-outs and Cancellations
Disabling Persistent TCP Connections
Posting Data over HTTP
Posting JSON to a Web Server
Posting a Multipart Form with Attached Files
What You’ve Learned
Chapter 9: Building HTTP Services
The Anatomy of a Go HTTP Server
Clients Don’t Respect Your Time
Adding TLS Support
Handlers
Test Your Handlers with httptest
How You Write the Response Matters
Any Type Can Be a Handler
Injecting Dependencies into Handlers
Middleware
Timing Out Slow Clients
Protecting Sensitive Files
Multiplexers
HTTP/2 Server Pushes
Pushing Resources to the Client
Don’t Be Too Pushy
What You’ve Learned
Chapter 10: Caddy: A Contemporary Web Server
What Is Caddy?
Let’s Encrypt Integration
How Does Caddy Fit into the Equation?
Retrieving Caddy
Downloading Caddy
Building Caddy from Source Code
Running and Configuring Caddy
Modifying Caddy’s Configuration in Real Time
Storing the Configuration in a File
Extending Caddy with Modules and Adapters
Writing a Configuration Adapter
Writing a Restrict Prefix Middleware Module
Injecting Your Module into Caddy
Reverse-Proxying Requests to a Backend Web Service
Creating a Simple Backend Web Service
Setting Up Caddy’s Configuration
Adding a Reverse-Proxy to Your Service
Serving Static Files
Checking Your Work
Adding Automatic HTTPS
What You’ve Learned
Chapter 11: Securing Communications with TLS
A Closer Look at Transport Layer Security
Forward Secrecy
In Certificate Authorities We Trust
How to Compromise TLS
Protecting Data in Transit
Client-side TLS
TLS over TCP
Server-side TLS
Certificate Pinning
Mutual TLS Authentication
Generating Certificates for Authentication
Implementing Mutual TLS
What You’ve Learned
Part IV : Service Architecture
Chapter 12: Data Serialization
Serializing Objects
JSON
Gob
Protocol Buffers
Transmitting Serialized Objects
Connecting Services with gRPC
Creating a TLS-Enabled gRPC Server
Creating a gRPC Client to Test the Server
What You’ve Learned
Chapter 13: Logging and Metrics
Event Logging
The log Package
Leveled Log Entries
Structured Logging
Scaling Up with Wide Event Logging
Log Rotation with Lumberjack
Instrumenting Your Code
Setup
Counters
Gauges
Histograms and Summaries
Instrumenting a Basic HTTP Server
What You’ve Learned
Chapter 14: Moving to the Cloud
Laying Some Groundwork
AWS Lambda
Installing the AWS Command Line Interface
Configuring the CLI
Creating a Role
Defining an AWS Lambda Function
Compiling, Packaging, and Deploying Your Function
Testing Your AWS Lambda Function
Google Cloud Functions
Installing the Google Cloud Software Development Kit
Initializing the Google Cloud SDK
Enable Billing and Cloud Functions
Defining a Cloud Function
Deploying Your Cloud Function
Testing Your Google Cloud Function
Azure Functions
Installing the Azure Command Line Interface
Configuring the Azure CLI
Installing Azure Functions Core Tools
Creating a Custom Handler
Defining a Custom Handler
Locally Testing the Custom Handler
Deploying the Custom Handler
Testing the Custom Handler
What You’ve Learned
Index
Search in book...
Toggle Font Controls
Playlists
Add To
Create new playlist
Name your new playlist
Playlist description (optional)
Cancel
Create playlist
Sign In
Email address
Password
Forgot Password?
Create account
Login
or
Continue with Facebook
Continue with Google
Sign Up
Full Name
Email address
Confirm Email Address
Password
Login
Create account
or
Continue with Facebook
Continue with Google
Prev
Previous Chapter
Chapter 2: Resource Location and Traffic Routing
Next
Next Chapter
Chapter 3: Reliable TCP Data Streams
Part II
Socket-level Programming
Add Highlight
No Comment
..................Content has been hidden....................
You can't read the all page of ebook, please click
here
login for view all page.
Day Mode
Cloud Mode
Night Mode
Reset