100% found this document useful (4 votes)
11 views

Network Programming with Go: Essential Skills for Using and Securing Networks 1st Edition Jan Newmarch instant download

The document provides information about various books related to network programming, particularly focusing on the Go programming language. It includes links to download these books and outlines their contents, including topics such as socket-level programming, data serialization, and security. Additionally, it mentions the authors and publication details for each book.

Uploaded by

ahaancbarriob
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
100% found this document useful (4 votes)
11 views

Network Programming with Go: Essential Skills for Using and Securing Networks 1st Edition Jan Newmarch instant download

The document provides information about various books related to network programming, particularly focusing on the Go programming language. It includes links to download these books and outlines their contents, including topics such as socket-level programming, data serialization, and security. Additionally, it mentions the authors and publication details for each book.

Uploaded by

ahaancbarriob
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 68

Network Programming with Go: Essential Skills

for Using and Securing Networks 1st Edition Jan


Newmarch pdf download

https://textbookfull.com/product/network-programming-with-go-
essential-skills-for-using-and-securing-networks-1st-edition-jan-
newmarch/

Download more ebook from https://textbookfull.com


We believe these products will be a great fit for you. Click
the link to download now, or visit textbookfull.com
to discover even more!

Network Programming with Go: Learn to Code Secure and


Reliable Network Services from Scratch 1st Edition Adam
Woodbeck

https://textbookfull.com/product/network-programming-with-go-
learn-to-code-secure-and-reliable-network-services-from-
scratch-1st-edition-adam-woodbeck/

Network Oriented Modeling for Adaptive Networks


Designing Higher Order Adaptive Biological Mental and
Social Network Models Jan Treur

https://textbookfull.com/product/network-oriented-modeling-for-
adaptive-networks-designing-higher-order-adaptive-biological-
mental-and-social-network-models-jan-treur/

Full-Stack Web Development with Go: Build your web


applications quickly using the Go programming language
and Vue.js 1st Edition Nanik Tolaram

https://textbookfull.com/product/full-stack-web-development-with-
go-build-your-web-applications-quickly-using-the-go-programming-
language-and-vue-js-1st-edition-nanik-tolaram/

Mastering Go Create Golang production applications


using network libraries concurrency and advanced Go
data structures 1st Edition Mihalis Tsoukalos

https://textbookfull.com/product/mastering-go-create-golang-
production-applications-using-network-libraries-concurrency-and-
advanced-go-data-structures-1st-edition-mihalis-tsoukalos/
Mastering Go create Golang production applications
using network libraries concurrency and advanced Go
data structures Second Edition Tsoukalos

https://textbookfull.com/product/mastering-go-create-golang-
production-applications-using-network-libraries-concurrency-and-
advanced-go-data-structures-second-edition-tsoukalos/

Black Hat Go Go Programming For Hackers and Pentesters


1st Edition Tom Steele

https://textbookfull.com/product/black-hat-go-go-programming-for-
hackers-and-pentesters-1st-edition-tom-steele/

Network Programming With Rust 1st Edition Abhishek


Chanda

https://textbookfull.com/product/network-programming-with-
rust-1st-edition-abhishek-chanda/

Black Hat Go Go Programming For Hackers And Pentesters


Tom Steele

https://textbookfull.com/product/black-hat-go-go-programming-for-
hackers-and-pentesters-tom-steele/

Programming Kotlin Enhance your skills for Android


development using Kotlin 2nd Edition Alexander
Aronowitz

https://textbookfull.com/product/programming-kotlin-enhance-your-
skills-for-android-development-using-kotlin-2nd-edition-
alexander-aronowitz/
Network
Programming
with Go
Essential Skills for Using and
Securing Networks

Jan Newmarch
Network Programming
with Go
Essential Skills for Using and
Securing Networks

Jan Newmarch
Network Programming with Go: Essential Skills for Using and Securing Networks
Jan Newmarch
Oakleigh, Victoria
Australia
ISBN-13 (pbk): 978-1-4842-2691-9 ISBN-13 (electronic): 978-1-4842-2692-6
DOI 10.1007/978-1-4842-2692-6
Library of Congress Control Number: 2017941517
Copyright © 2017 by Jan Newmarch
This work is subject to copyright. All rights are reserved by the Publisher, whether the whole or part of the
material is concerned, specifically the rights of translation, reprinting, reuse of illustrations, recitation,
broadcasting, reproduction on microfilms or in any other physical way, and transmission or information
storage and retrieval, electronic adaptation, computer software, or by similar or dissimilar methodology now
known or hereafter developed.
Trademarked names, logos, and images may appear in this book. Rather than use a trademark symbol
with every occurrence of a trademarked name, logo, or image we use the names, logos, and images only
in an editorial fashion and to the benefit of the trademark owner, with no intention of infringement of the
trademark.
The use in this publication of trade names, trademarks, service marks, and similar terms, even if they are
not identified as such, is not to be taken as an expression of opinion as to whether or not they are subject to
proprietary rights.
While the advice and information in this book are believed to be true and accurate at the date of publication,
neither the authors nor the editors nor the publisher can accept any legal responsibility for any errors or
omissions that may be made. The publisher makes no warranty, express or implied, with respect to the
material contained herein.
Managing Director: Welmoed Spahr
Editorial Director: Todd Green
Acquisitions Editor: Steve Anglin
Development Editor: Matthew Moodie
Technical Reviewer: Ronald Petty
Coordinating Editor: Mark Powers
Copy Editor: Kezia Endsley
Compositor: SPi Global
Indexer: SPi Global
Artist: SPi Global
Cover image designed by Freepik
Distributed to the book trade worldwide by Springer Science+Business Media New York,
233 Spring Street, 6th Floor, New York, NY 10013. Phone 1-800-SPRINGER, fax (201) 348-4505, e-mail
[email protected], or visit www.springeronline.com. Apress Media, LLC is a California LLC
and the sole member (owner) is Springer Science + Business Media Finance Inc (SSBM Finance Inc). SSBM
Finance Inc is a Delaware corporation.
For information on translations, please e-mail [email protected], or visit http://www.apress.com/
rights-permissions.
Apress titles may be purchased in bulk for academic, corporate, or promotional use. eBook versions and
licenses are also available for most titles. For more information, reference our Print and eBook Bulk Sales
web page at http://www.apress.com/bulk-sales.
Any source code or other supplementary material referenced by the author in this book is available to
readers on GitHub via the book's product page, located at www.apress.com/9781484226919. For more
detailed information, please visit http://www.apress.com/source-code.
Printed on acid-free paper
Contents at a Glance

About the Author���������������������������������������������������������������������������������������������������xvii


About the Technical Reviewer��������������������������������������������������������������������������������xix
Preface�������������������������������������������������������������������������������������������������������������������xxi


■Chapter 1: Architecture����������������������������������������������������������������������������������������� 1

■Chapter 2: Overview of the Go Language������������������������������������������������������������ 21

■Chapter 3: Socket-Level Programming���������������������������������������������������������������� 29

■Chapter 4: Data Serialization������������������������������������������������������������������������������� 57

■Chapter 5: Application-Level Protocols��������������������������������������������������������������� 87

■Chapter 6: Managing Character Sets and Encodings���������������������������������������� 107

■Chapter 7: Security�������������������������������������������������������������������������������������������� 121

■Chapter 8: HTTP������������������������������������������������������������������������������������������������� 137

■Chapter 9: Templates����������������������������������������������������������������������������������������� 161

■Chapter 10: A Complete Web Server������������������������������������������������������������������ 175

■Chapter 11: HTML���������������������������������������������������������������������������������������������� 193

■Chapter 12: XML������������������������������������������������������������������������������������������������ 199

■Chapter 13: Remote Procedure Call������������������������������������������������������������������ 209

■Chapter 14: REST����������������������������������������������������������������������������������������������� 221

■Chapter 15: WebSockets������������������������������������������������������������������������������������ 247
Afterword�������������������������������������������������������������������������������������������������������������� 267

Index��������������������������������������������������������������������������������������������������������������������� 269

iii
Contents

About the Author���������������������������������������������������������������������������������������������������xvii


About the Technical Reviewer��������������������������������������������������������������������������������xix
Preface�������������������������������������������������������������������������������������������������������������������xxi


■Chapter 1: Architecture����������������������������������������������������������������������������������������� 1
Protocol Layers����������������������������������������������������������������������������������������������������������������� 1
ISO OSI Protocol�������������������������������������������������������������������������������������������������������������������������������������� 2
OSI Layers����������������������������������������������������������������������������������������������������������������������������������������������� 2
TCP/IP Protocol��������������������������������������������������������������������������������������������������������������������������������������� 3
Some Alternative Protocols�������������������������������������������������������������������������������������������������������������������� 3

Networking����������������������������������������������������������������������������������������������������������������������� 3
Gateways�������������������������������������������������������������������������������������������������������������������������� 4
Packet Encapsulation������������������������������������������������������������������������������������������������������� 4
Connection Models����������������������������������������������������������������������������������������������������������� 5
Connection Oriented������������������������������������������������������������������������������������������������������������������������������� 5
Connectionless��������������������������������������������������������������������������������������������������������������������������������������� 5

Communications Models�������������������������������������������������������������������������������������������������� 5
Message Passing������������������������������������������������������������������������������������������������������������������������������������ 5
Remote Procedure Call��������������������������������������������������������������������������������������������������������������������������� 6

Distributed Computing Models����������������������������������������������������������������������������������������� 7


Client-Server System������������������������������������������������������������������������������������������������������� 8
Client-Server Application������������������������������������������������������������������������������������������������� 8
Server Distribution����������������������������������������������������������������������������������������������������������� 9

v
■ Contents

Communication Flows������������������������������������������������������������������������������������������������������ 9
Synchronous Communication��������������������������������������������������������������������������������������������������������������� 10
Asynchronous Communication������������������������������������������������������������������������������������������������������������� 10
Streaming Communication������������������������������������������������������������������������������������������������������������������� 10
Publish/Subscribe��������������������������������������������������������������������������������������������������������������������������������� 10

Component Distribution�������������������������������������������������������������������������������������������������� 10
Gartner Classification��������������������������������������������������������������������������������������������������������������������������� 11
Three-Tier Models�������������������������������������������������������������������������������������������������������������������������������� 13
Fat versus Thin������������������������������������������������������������������������������������������������������������������������������������� 14

Middleware Model���������������������������������������������������������������������������������������������������������� 14
Middleware Examples�������������������������������������������������������������������������������������������������������������������������� 14
Middleware Functions�������������������������������������������������������������������������������������������������������������������������� 15

Continuum of Processing����������������������������������������������������������������������������������������������� 15
Points of Failure������������������������������������������������������������������������������������������������������������� 16
Acceptance Factors�������������������������������������������������������������������������������������������������������� 16
Transparency������������������������������������������������������������������������������������������������������������������ 17
Access Transparency���������������������������������������������������������������������������������������������������������������������������� 17
Location Transparency�������������������������������������������������������������������������������������������������������������������������� 17
Migration Transparency������������������������������������������������������������������������������������������������������������������������ 17
Replication Transparency���������������������������������������������������������������������������������������������������������������������� 17
Concurrency Transparency������������������������������������������������������������������������������������������������������������������� 17
Scalability Transparency����������������������������������������������������������������������������������������������������������������������� 17
Performance Transparency������������������������������������������������������������������������������������������������������������������� 18
Failure Transparency���������������������������������������������������������������������������������������������������������������������������� 18

Eight Fallacies of Distributed Computing����������������������������������������������������������������������� 18


Fallacy: The Network Is Reliable����������������������������������������������������������������������������������������������������������� 18
Fallacy: Latency Is Zero������������������������������������������������������������������������������������������������������������������������ 19
Fallacy: Bandwidth Is Infinite��������������������������������������������������������������������������������������������������������������� 19
Fallacy: The Network Is Secure������������������������������������������������������������������������������������������������������������ 19

vi
■ Contents

Fallacy: Topology Doesn’t Change�������������������������������������������������������������������������������������������������������� 19


Fallacy: There Is One Administrator������������������������������������������������������������������������������������������������������ 19
Fallacy: Transport Cost Is Zero�������������������������������������������������������������������������������������������������������������� 20
Fallacy: The Network Is Homogeneous������������������������������������������������������������������������������������������������� 20

Conclusion���������������������������������������������������������������������������������������������������������������������� 20

■Chapter 2: Overview of the Go Language������������������������������������������������������������ 21
Types������������������������������������������������������������������������������������������������������������������������������ 22
Slices and Arrays���������������������������������������������������������������������������������������������������������������������������������� 22
Structures��������������������������������������������������������������������������������������������������������������������������������������������� 22
Pointers������������������������������������������������������������������������������������������������������������������������������������������������ 23
Functions���������������������������������������������������������������������������������������������������������������������������������������������� 23
Maps����������������������������������������������������������������������������������������������������������������������������������������������������� 24
Methods������������������������������������������������������������������������������������������������������������������������������������������������ 24

Multi-Threading�������������������������������������������������������������������������������������������������������������� 25
Packages������������������������������������������������������������������������������������������������������������������������ 25
Type Conversion������������������������������������������������������������������������������������������������������������� 25
Statements��������������������������������������������������������������������������������������������������������������������� 25
GOPATH��������������������������������������������������������������������������������������������������������������������������� 25
Running Go Programs���������������������������������������������������������������������������������������������������� 26
Standard Libraries���������������������������������������������������������������������������������������������������������� 26
Error Values�������������������������������������������������������������������������������������������������������������������� 26
Conclusion���������������������������������������������������������������������������������������������������������������������� 27

■Chapter 3: Socket-Level Programming���������������������������������������������������������������� 29
The TCP/IP Stack������������������������������������������������������������������������������������������������������������ 29
IP Datagrams���������������������������������������������������������������������������������������������������������������������������������������� 30
UDP������������������������������������������������������������������������������������������������������������������������������������������������������� 30
TCP������������������������������������������������������������������������������������������������������������������������������������������������������� 30

Internet Addresses��������������������������������������������������������������������������������������������������������� 30
IPv4 Addresses������������������������������������������������������������������������������������������������������������������������������������� 31
IPv6 Addresses������������������������������������������������������������������������������������������������������������������������������������� 31

vii
■ Contents

IP Address Type�������������������������������������������������������������������������������������������������������������� 32
The IPMask Type����������������������������������������������������������������������������������������������������������������������������������� 33
The IPAddr Type������������������������������������������������������������������������������������������������������������������������������������ 36
Host Lookup������������������������������������������������������������������������������������������������������������������������������������������ 37

Services������������������������������������������������������������������������������������������������������������������������� 38
Ports����������������������������������������������������������������������������������������������������������������������������������������������������� 38
The TCPAddr Type��������������������������������������������������������������������������������������������������������������������������������� 39

TCP Sockets������������������������������������������������������������������������������������������������������������������� 40
TCP Client��������������������������������������������������������������������������������������������������������������������������������������������� 40
A Daytime Server���������������������������������������������������������������������������������������������������������������������������������� 42
Multi-Threaded Server������������������������������������������������������������������������������������������������������������������������� 44

Controlling TCP Connections������������������������������������������������������������������������������������������ 46


Timeout������������������������������������������������������������������������������������������������������������������������������������������������� 46
Staying Alive����������������������������������������������������������������������������������������������������������������������������������������� 46

UDP Datagrams�������������������������������������������������������������������������������������������������������������� 47
Server Listening on Multiple Sockets����������������������������������������������������������������������������� 49
The Conn, PacketConn, and Listener Types�������������������������������������������������������������������� 49
Raw Sockets and the IPConn Type��������������������������������������������������������������������������������� 52
Conclusion���������������������������������������������������������������������������������������������������������������������� 55

■Chapter 4: Data Serialization������������������������������������������������������������������������������� 57
Structured Data�������������������������������������������������������������������������������������������������������������� 57
Mutual Agreement���������������������������������������������������������������������������������������������������������� 59
Self-Describing Data������������������������������������������������������������������������������������������������������ 59
ASN.1������������������������������������������������������������������������������������������������������������������������������ 60
ASN.1 Daytime Client and Server��������������������������������������������������������������������������������������������������������� 66

JSON������������������������������������������������������������������������������������������������������������������������������ 68
A Client and Server������������������������������������������������������������������������������������������������������������������������������� 72

The Gob Package������������������������������������������������������������������������������������������������������������ 75


A Client and Server������������������������������������������������������������������������������������������������������������������������������� 78

viii
■ Contents

Encoding Binary Data as Strings������������������������������������������������������������������������������������ 81


Protocol Buffers�������������������������������������������������������������������������������������������������������������� 83
Installing and Compiling Protocol Buffers�������������������������������������������������������������������������������������������� 84
The Compiled personv3.pb.go File������������������������������������������������������������������������������������������������������� 84
Using the Compiled Code��������������������������������������������������������������������������������������������������������������������� 85

Conclusion���������������������������������������������������������������������������������������������������������������������� 86

■Chapter 5: Application-Level Protocols��������������������������������������������������������������� 87
Protocol Design�������������������������������������������������������������������������������������������������������������� 87
Why Should You Worry?�������������������������������������������������������������������������������������������������� 88
Version Control��������������������������������������������������������������������������������������������������������������� 88
The Web������������������������������������������������������������������������������������������������������������������������������������������������ 89

Message Format������������������������������������������������������������������������������������������������������������ 90
Data Format������������������������������������������������������������������������������������������������������������������� 91
Byte Format������������������������������������������������������������������������������������������������������������������������������������������ 91
Character Format���������������������������������������������������������������������������������������������������������������������������������� 92

A Simple Example���������������������������������������������������������������������������������������������������������� 92
A Standalone Application���������������������������������������������������������������������������������������������������������������������� 93
The Client-Server Application��������������������������������������������������������������������������������������������������������������� 94
The Client Side�������������������������������������������������������������������������������������������������������������������������������������� 94
Alternative Presentation Aspects���������������������������������������������������������������������������������������������������������� 95
The Server Side������������������������������������������������������������������������������������������������������������������������������������ 95
Protocol: Informal��������������������������������������������������������������������������������������������������������������������������������� 95
Text Protocol����������������������������������������������������������������������������������������������������������������������������������������� 96
Server Code������������������������������������������������������������������������������������������������������������������������������������������ 97
Client Code������������������������������������������������������������������������������������������������������������������������������������������� 99
Textproto Package������������������������������������������������������������������������������������������������������������������������������ 101

State Information��������������������������������������������������������������������������������������������������������� 101


Application State Transition Diagram������������������������������������������������������������������������������������������������� 103
Client State Transition Diagrams�������������������������������������������������������������������������������������������������������� 104

ix
■ Contents

Server State Transition Diagrams������������������������������������������������������������������������������������������������������� 105


Server Pseudocode����������������������������������������������������������������������������������������������������������������������������� 105

Conclusion�������������������������������������������������������������������������������������������������������������������� 106

■Chapter 6: Managing Character Sets and Encodings���������������������������������������� 107
Definitions�������������������������������������������������������������������������������������������������������������������� 108
Character�������������������������������������������������������������������������������������������������������������������������������������������� 108
Character Repertoire/Character Set��������������������������������������������������������������������������������������������������� 108
Character Code����������������������������������������������������������������������������������������������������������������������������������� 108
Character Encoding���������������������������������������������������������������������������������������������������������������������������� 108
Transport Encoding����������������������������������������������������������������������������������������������������������������������������� 109

ASCII����������������������������������������������������������������������������������������������������������������������������� 109
ISO 8859����������������������������������������������������������������������������������������������������������������������� 111
Unicode������������������������������������������������������������������������������������������������������������������������ 111
UTF-8, Go, and Runes��������������������������������������������������������������������������������������������������� 112
UTF-8 Client and Server��������������������������������������������������������������������������������������������������������������������� 112
ASCII Client and Server����������������������������������������������������������������������������������������������������������������������� 113

UTF-16 and Go�������������������������������������������������������������������������������������������������������������� 113


Little-Endian and Big-Endian�������������������������������������������������������������������������������������������������������������� 113
UTF-16 Client and Server������������������������������������������������������������������������������������������������������������������� 114

Unicode Gotchas���������������������������������������������������������������������������������������������������������� 116


ISO 8859 and Go����������������������������������������������������������������������������������������������������������� 117
Other Character Sets and Go���������������������������������������������������������������������������������������� 119
Conclusion�������������������������������������������������������������������������������������������������������������������� 119

■Chapter 7: Security�������������������������������������������������������������������������������������������� 121
ISO Security Architecture��������������������������������������������������������������������������������������������� 121
Functions and Levels�������������������������������������������������������������������������������������������������������������������������� 122
Mechanisms��������������������������������������������������������������������������������������������������������������������������������������� 123

Data Integrity���������������������������������������������������������������������������������������������������������������� 124


Symmetric Key Encryption������������������������������������������������������������������������������������������� 126
Public Key Encryption��������������������������������������������������������������������������������������������������� 127
x
■ Contents

X.509 Certificates��������������������������������������������������������������������������������������������������������� 129


TLS������������������������������������������������������������������������������������������������������������������������������� 132
A Basic Client�������������������������������������������������������������������������������������������������������������������������������������� 132
Server Using a Self-Signed Certificate����������������������������������������������������������������������������������������������� 133

Conclusion�������������������������������������������������������������������������������������������������������������������� 136

■Chapter 8: HTTP������������������������������������������������������������������������������������������������� 137
URLs and Resources���������������������������������������������������������������������������������������������������� 137
I18n����������������������������������������������������������������������������������������������������������������������������������������������������� 137
HTTP Characteristics�������������������������������������������������������������������������������������������������������������������������� 138
Versions���������������������������������������������������������������������������������������������������������������������������������������������� 138
HTTP 0.9��������������������������������������������������������������������������������������������������������������������������������������������� 138
HTTP 1.0��������������������������������������������������������������������������������������������������������������������������������������������� 139
HTTP 1.1��������������������������������������������������������������������������������������������������������������������������������������������� 140
HTTP/2������������������������������������������������������������������������������������������������������������������������������������������������ 141

Simple User Agents������������������������������������������������������������������������������������������������������ 141


The Response Type����������������������������������������������������������������������������������������������������������������������������� 141
The HEAD Method������������������������������������������������������������������������������������������������������������������������������� 142
The GET Method��������������������������������������������������������������������������������������������������������������������������������� 143

Configuring HTTP Requests������������������������������������������������������������������������������������������ 145


The Client Object���������������������������������������������������������������������������������������������������������� 147
Proxy Handling������������������������������������������������������������������������������������������������������������� 149
Simple Proxy��������������������������������������������������������������������������������������������������������������������������������������� 149
Authenticating Proxy�������������������������������������������������������������������������������������������������������������������������� 151

HTTPS Connections by Clients�������������������������������������������������������������������������������������� 153


Servers������������������������������������������������������������������������������������������������������������������������� 155
File Server������������������������������������������������������������������������������������������������������������������������������������������ 155
Handler Functions������������������������������������������������������������������������������������������������������������������������������ 156
Bypassing the Default Multiplexer������������������������������������������������������������������������������������������������������ 158

HTTPS��������������������������������������������������������������������������������������������������������������������������� 159
Conclusion�������������������������������������������������������������������������������������������������������������������� 160

xi
■ Contents


■Chapter 9: Templates����������������������������������������������������������������������������������������� 161
Inserting Object Values������������������������������������������������������������������������������������������������� 161
Using Templates��������������������������������������������������������������������������������������������������������������������������������� 162

Pipelines����������������������������������������������������������������������������������������������������������������������� 164
Defining Functions������������������������������������������������������������������������������������������������������� 165
Variables����������������������������������������������������������������������������������������������������������������������� 167
Conditional Statements������������������������������������������������������������������������������������������������ 168
The HTML / Template Package�������������������������������������������������������������������������������������� 173
Conclusion�������������������������������������������������������������������������������������������������������������������� 173

■Chapter 10: A Complete Web Server������������������������������������������������������������������ 175
Browser Site Diagram�������������������������������������������������������������������������������������������������� 175
Browser Files��������������������������������������������������������������������������������������������������������������� 177
Basic Server����������������������������������������������������������������������������������������������������������������� 177
The listFlashCards Function����������������������������������������������������������������������������������������� 179
The manageFlashCards Function��������������������������������������������������������������������������������� 181
The Chinese Dictionary������������������������������������������������������������������������������������������������ 181
The Dictionary Type ��������������������������������������������������������������������������������������������������������������������������� 182

Flashcard Sets�������������������������������������������������������������������������������������������������������������� 183


Fixing Accents�������������������������������������������������������������������������������������������������������������� 184
The ListWords Function������������������������������������������������������������������������������������������������ 187
The showFlashCards Function������������������������������������������������������������������������������������� 189
Presentation on the Browser���������������������������������������������������������������������������������������� 191
Running the Server������������������������������������������������������������������������������������������������������ 191
Conclusion�������������������������������������������������������������������������������������������������������������������� 191

■Chapter 11: HTML���������������������������������������������������������������������������������������������� 193
The Go HTML/Template Package���������������������������������������������������������������������������������� 194
Tokenizing HTML���������������������������������������������������������������������������������������������������������� 195
XHTML/HTML���������������������������������������������������������������������������������������������������������������� 197

xii
■ Contents

JSON���������������������������������������������������������������������������������������������������������������������������� 198
Conclusion�������������������������������������������������������������������������������������������������������������������� 198

■Chapter 12: XML������������������������������������������������������������������������������������������������ 199
Parsing XML����������������������������������������������������������������������������������������������������������������� 200
The StartElement Type������������������������������������������������������������������������������������������������������������������������ 200
The EndElement Type������������������������������������������������������������������������������������������������������������������������� 200
The CharData Type������������������������������������������������������������������������������������������������������������������������������ 200
The Comment Type����������������������������������������������������������������������������������������������������������������������������� 200
The ProcInst Type������������������������������������������������������������������������������������������������������������������������������� 201
The Directive Type������������������������������������������������������������������������������������������������������������������������������ 201

Unmarshalling XML������������������������������������������������������������������������������������������������������ 203


Marshalling XML����������������������������������������������������������������������������������������������������������� 206
XHTML�������������������������������������������������������������������������������������������������������������������������� 207
HTML���������������������������������������������������������������������������������������������������������������������������� 207
Conclusion�������������������������������������������������������������������������������������������������������������������� 207

■Chapter 13: Remote Procedure Call������������������������������������������������������������������ 209
Go’s RPC����������������������������������������������������������������������������������������������������������������������� 210
HTTP RPC Server�������������������������������������������������������������������������������������������������������������������������������� 212
HTTP RPC Client���������������������������������������������������������������������������������������������������������������������������������� 213
TCP RPC Server���������������������������������������������������������������������������������������������������������������������������������� 214
TCP RPC Client������������������������������������������������������������������������������������������������������������������������������������ 216
Matching Values��������������������������������������������������������������������������������������������������������������������������������� 217

JSON���������������������������������������������������������������������������������������������������������������������������� 217
JSON RPC Server�������������������������������������������������������������������������������������������������������������������������������� 218
JSON RPC Client��������������������������������������������������������������������������������������������������������������������������������� 219

Conclusion�������������������������������������������������������������������������������������������������������������������� 220

■Chapter 14: REST����������������������������������������������������������������������������������������������� 221
URIs and Resources����������������������������������������������������������������������������������������������������� 221
Representations����������������������������������������������������������������������������������������������������������� 222

xiii
■ Contents

REST Verbs������������������������������������������������������������������������������������������������������������������� 223


The GET Verb�������������������������������������������������������������������������������������������������������������������������������������� 223
The PUT Verb�������������������������������������������������������������������������������������������������������������������������������������� 223
The DELETE Verb��������������������������������������������������������������������������������������������������������������������������������� 224
The POST Verb������������������������������������������������������������������������������������������������������������������������������������ 224

No Maintained State����������������������������������������������������������������������������������������������������� 224


HATEOAS���������������������������������������������������������������������������������������������������������������������� 224
Representing Links������������������������������������������������������������������������������������������������������� 225
Transactions with REST������������������������������������������������������������������������������������������������ 226
The Richardson Maturity Model����������������������������������������������������������������������������������� 227
Flashcards Revisited���������������������������������������������������������������������������������������������������� 228
URLs��������������������������������������������������������������������������������������������������������������������������������������������������� 228

The Demultiplexer (Demuxer)��������������������������������������������������������������������������������������� 229


Content Negotiation������������������������������������������������������������������������������������������������������ 230
GET /��������������������������������������������������������������������������������������������������������������������������������������������������� 232
POST /������������������������������������������������������������������������������������������������������������������������������������������������� 233

Handling Other URLs���������������������������������������������������������������������������������������������������� 234


The Complete Server���������������������������������������������������������������������������������������������������� 234
Client���������������������������������������������������������������������������������������������������������������������������� 240
Using REST or RPC������������������������������������������������������������������������������������������������������� 245
Conclusion�������������������������������������������������������������������������������������������������������������������� 245

■Chapter 15: WebSockets������������������������������������������������������������������������������������ 247
WebSockets Server������������������������������������������������������������������������������������������������������ 248
The Go Sub-Repository Package���������������������������������������������������������������������������������� 248
The Message Object��������������������������������������������������������������������������������������������������������������������������� 248
The JSON Object��������������������������������������������������������������������������������������������������������������������������������� 251
The Codec Type����������������������������������������������������������������������������������������������������������������������������������� 254
WebSockets Over TLS������������������������������������������������������������������������������������������������������������������������� 257
WebSockets in an HTML Page������������������������������������������������������������������������������������������������������������ 259

xiv
■ Contents

The Gorilla Package������������������������������������������������������������������������������������������������������ 263


Echo Server���������������������������������������������������������������������������������������������������������������������������������������� 264
Echo Client������������������������������������������������������������������������������������������������������������������������������������������ 265

Conclusion�������������������������������������������������������������������������������������������������������������������� 266
Afterword�������������������������������������������������������������������������������������������������������������� 267

Index��������������������������������������������������������������������������������������������������������������������� 269

xv
About the Author

Jan Newmarch is head of ICT (higher education) at Box Hill Institute, adjunct
professor at Canberra University, and adjunct lecturer in the School of
Information Technology, Computing and Mathematics at Charles Sturt
University. He is interested in more aspects of computing than he has time to
pursue, but the major thrust over the last few years has developed from user
interfaces under UNIX into Java, the Web, and then into general distributed
systems. Jan developed a number of publicly available software systems in
these areas. For the last few years, he has been looking at sound for Linux
systems and programming the Raspberry Pi’s GPU. He is now exploring
aspects of the IoT. He lives in Melbourne, Australia and enjoys the food and
culture there, but is not so impressed by the weather.

xvii
About the Technical Reviewer

Ronald Petty, M.B.A., M.S. is the founder of Minimum Distance LLC, a


management consulting firm based in San Francisco. He spends his time
helping technology-based startups do the right thing. He is also an
instructor at UC Berkeley Extension.

xix
Preface

It’s always fun to learn a new programming language, especially when it turns out to be a major one. Prior
to the release of Go in 2009, I was teaching a Master’s level subject in network programming at Monash
University. It’s good to have a goal when learning a new language, but this time, instead of building yet
another wine cellar program, I decided to orient my lecture notes around Go instead of my (then) standard
delivery vehicle of Java.
The experiment worked well: apart from the richness of the Java libraries that Go was yet to match, all
the programming examples transferred remarkably well, and in many cases were more elegant than the
original Java programs.
This book is the result. I have updated it as Go has evolved and as new technologies such as HTTP/2
have arisen. But if it reads like a textbook, well, that is because it is one. There is a large body of theoretical
and practical concepts involved in network programming and this book covers some of these as well as the
practicalities of building systems in Go.
In terms of language popularity, Go is clearly rising. It has climbed to 16th in the TIOBE index, is 18th
in the PYPL (Popularity of Programming Language), and is 15th in the RedMonk Programming Language
rankings. It is generally rated as one of the fastest growing languages.
There is a growing community of developers both of the core language and libraries and of the
independent projects. I have tried to limit the scope of this book to the standard libraries only and to the
“sub-repositories” of the Go tree. While this eliminates many excellent projects that no doubt make many
programming tasks easier, restricting the book to the official Go libraries provides a clear bound.
This book assumes a basic knowledge of Go. The focus is on using Go to build network applications,
not on the basics of the language. Network applications are different than command-line applications,
are different than applications with a graphical user interface, and so on. So the first chapter discusses
architectural aspects of network programs. The second chapter is an overview of the features of Go that we
use in this book. The third chapter on sockets covers the Go version of the basics underlying all
TCP/IP systems. Chapters 4, 5, and 6 are more unusual in network programming books. They cover the
topics of what representations of data will be used, how a network interaction will proceed, and for text,
which language formats are used. Then in Chapter 7, we look at the increasingly important topic of security.
In Chapter 8, we look at one of the most common application layer protocols in use, HTTP. The next four
chapters are about topics related to HTTP and common data formats carried above HTTP—HTML and
XML. In Chapter 13, we look at an alternative approach to network programming, remote procedure calls.
Chapters 14 and 15 consider further aspects of network programming using HTTP.

xxi
CHAPTER 1

Architecture

This chapter covers the major architectural features of distributed systems. You can’t build a system without
some idea of what you want to build. And you can’t build it if you don't know the environment in which it
will work. GUI programs are different than batch processing programs; games programs are different than
business programs; and distributed programs are different than standalone programs. They each have their
approaches, their common patterns, the problems that typically arise, and the solutions that are often used.
This chapter covers the high-level architectural aspects of distributed systems. There are many ways of
looking at such systems, and many of these are dealt with.

Protocol Layers
Distributed systems are hard. There are multiple computers involved, which have to be connected in some
way. Programs have to be written to run on each computer in the system and they all have to cooperate to
get a distributed task done.
The common way to deal with complexity is to break it down into smaller and simpler parts. These
parts have their own structure, but they also have defined means of communicating with other related parts.
In distributed systems, the parts are called protocol layers and they have clearly defined functions. They
form a stack, with each layer communicating with the layer above and the layer below. The communication
between layers is defined by protocols.
Network communications requires protocols to cover high-level application communication all the way
down to wire communication and the complexity handled by encapsulation in protocol layers.

© Jan Newmarch 2017 1


J. Newmarch, Network Programming with Go, DOI 10.1007/978-1-4842-2692-6_1
Chapter 1 ■ Architecture

ISO OSI Protocol


Although it was never properly implemented, the OSI (Open Systems Interconnect) protocol has been a
major influence in ways of talking about and influencing distributed systems design. It is commonly given as
shown in Figure 1-1.

Application Application
Presentation Presentation
Session Session
Transport Transport
Network Network
Data Link Data Link
Physical Physical

Figure 1-1. The Open Systems Interconnect protocol

OSI Layers
The function of each layer from bottom to top is as follows:
• The Physical layer conveys the bit stream using electrical, optical, or radio
technologies.
• The Data link layer puts the information packets into network frames for
transmission across the physical layer, and back into information packets.
• The Network layer provides switching and routing technologies.
• The Transport layer provides transparent transfer of data between end systems and
is responsible for end-to-end error recovery and flow control.
• The Session layer establishes, manages, and terminates connections between
applications.
• The Presentation layer provides independence from differences in data
representation (e.g., encryption).
• The Application layer supports application and end-user processes.

2
Chapter 1 ■ Architecture

TCP/IP Protocol
While the OSI model was being argued, debated, partly implemented, and fought over, the DARPA Internet
research project was busy building the TCP/IP protocols. These have been immensely successful and have
led to The Internet (with capitals). This is a much simpler stack, as shown in Figure 1-2.

application application OSI 5−7

TCP UDP OSI 4

IP OSI 3

h/w interface OSI 1−2

Figure 1-2. The TCP/IP protocols

Some Alternative Protocols


Although it almost seems like it, the TCP/IP protocols are not the only ones in existence and in the long run
may not even be the most successful. Wikipedia’s list of network protocols (see https://en.wikipedia.
org/wiki/List_of_network_protocols_(OSI_model)) has a huge number more, at each of the ISO layers.
Many of these are obsolete or of little use, but due to advances in technology in all sorts of areas—such as the
Internet in Space and the Internet of Things—there will always be room for new protocols.
The focus in this book is on the TCP/IP (including UDP) layer, but you should be aware that there are
other ones.

Networking
A network is a communications system for connecting end systems called hosts. The mechanisms of
connection might be copper wire, Ethernet, fiber optic, or wireless, but that won’t concern us here. A local
area network (LAN) connects computers that are close together, typically belonging to a home, small
organization, or part of a larger organization.
A Wide Area Network (WAN) connects computers across a larger physical area, such as between cities.
There are other types as well, such as MANs (Metropolitan Area Network), PANs (Personal Area Networks),
and even BANs (Body Area Network).
An internet is a connection of two or more distinct networks, typically LANs or WANs. An intranet is an
internet with all networks belonging to a single organization.
There are significant differences between an internet and an intranet. Typically, an intranet will be
under a single administrative control, which will impose a single set of coherent policies. An internet, on the
other hand, will not be under the control of a single body, and the controls exercised over different parts may
not even be compatible.

3
Chapter 1 ■ Architecture

A trivial example of such differences is that an intranet will often be restricted to computers by a small
number of vendors running a standardized version of a particular operating system. On the other hand, an
internet will often have a smorgasbord of different computers and operating systems.
The techniques of this book are applicable to internets. They are also valid with intranets, but there you
will also find specialized, non-portable systems.
And then there is the “mother” of all internets: The Internet. This is just a very, very large internet that
connects us to Google, my computer to your computer, and so on.

Gateways
A gateway is a generic term for an entity used to connect two or more networks. A repeater operates at
the physical level and copies information from one subnet to another. A bridge operates at the data link
layer level and copies frames between networks. A router operates at the network level and not only moves
information between networks but also decides on the route.

Packet Encapsulation
The communication between layers in either the OSI or the TCP/IP stacks is done by sending packets of
data from one layer to the next, and then eventually across the network. Each layer has administrative
information that it has to keep about its own layer. It does this by adding header information to the packet it
receives from the layer above, as the packet passes down. On the receiving side, these headers are removed
as the packet moves up.
For example, the TFTP (Trivial File Transfer Protocol) moves files from one computer to another. It uses
the UDP protocol on top of the IP protocol, which may be sent over Ethernet. This looks like the diagram
shown in Figure 1-3.

data

TFTP
data
header

UDP TFTP
data
header header

IP UDP TFTP
data
header header header

ethernet IP UDP TFTP


data
header header header header

Figure 1-3. The TFTP (Trivial File Transfer Protocol)

4
Chapter 1 ■ Architecture

The packet transmitted over Ethernet is of course the bottom one.

Connection Models
In order for two computers to communicate, they must set up a path whereby they can send at least one
message in a session. There are two major models for this:
• Connection oriented
• Connectionless

Connection Oriented
A single connection is established for the session. Two-way communications flow along the connection. When
the session is over, the connection is broken. The analogy is to a phone conversation. An example is TCP.

Connectionless
In a connectionless system, messages are sent independent of each other. Ordinary mail is the analogy.
Connectionless messages may arrive out of order. An example is the IP protocol. UDP is a connectionless
protocol above IP and is often used as an alternative to TCP, as it is much lighter weight.
Connection-oriented transports may be established on top of connectionless ones—TCP over IP.
Connectionless transports may be established on top of connection-oriented ones—HTTP over TCP.
There can be variations on these. For example, a session might enforce messages arriving, but might not
guarantee that they arrive in the order sent. However, these two are the most common.

Communications Models
In a distributed system there will be many components running that have to communicate with each other.
There are two primary models for this, message passing and remote procedure calls.

Message Passing
Some non-procedural languages are built on the principle of message passing. Concurrent languages often
use such a mechanism, and the most well known example is probably the UNIX pipeline. The UNIX pipeline
is a pipeline of bytes, but this is not an inherent limitation: Microsoft’s PowerShell can send objects along
its pipelines, and concurrent languages such as Parlog can send arbitrary logic data structures in messages
between concurrent processes.
Message passing is a primitive mechanism for distributed systems. Set up a connection and pump some
data down it. At the other end, figure out what the message was and respond to it, possibly sending messages
back. This is illustrated in Figure 1-4.

5
Chapter 1 ■ Architecture

Requestor Responder

Send(Msg, Responder)

Receive(Msg, Requestor)

Send(Reply, Requestor)

Receive(Reply, Responder)

Figure 1-4. The message passing communications model

Event-driven systems act in a similar manner. At a low level, node.js runs an event loop waiting for I/O
events, dispatching handlers for these events and responding. At a higher level, most user interface systems
use an event loop waiting for user input, while in the networking world, Ajax uses the XMLHttpRequest to
send and receive requests.

Remote Procedure Call


In any system, there is a transfer of information and flow control from one part of the system to another. In
procedural languages, this may consist of the procedure call, where information is placed on a call stack and
then control flow is transferred to another part of the program.
Even with procedure calls, there are variations. The code may be statically linked so that control
transfers from one part of the program’s executable code to another part. Due to the increasing use of library
routines, it has become commonplace to have such code in dynamic link libraries (DLLs), where control
transfers to an independent piece of code.
DLLs run in the same machine as the calling code. it is a simple (conceptual) step to transfer control to
a procedure running in a different machine. The mechanics of this are not so simple! However, this model
of control has given rise to the remote procedure call (RPC), which is discussed in much detail in a later
chapter. This is illustrated by Figure 1-5.

6
Chapter 1 ■ Architecture

Client Process
main()
{

rpc(a, b, c)
Server Process

}
receive(x, y)

send(x=a, y=b) rpc(x, y, z)


{
receive(c=z) ...
}

send(z)

Figure 1-5. The remote procedure call communications model

There are many examples of this: some based on particular programming languages such as the Go
rpc package (discussed in Chapter 13) or RPC systems covering multiple languages such as SOAP and
Google’s grpc.

Distributed Computing Models


At the highest level, we could consider the equivalence or the non-equivalence of components of a
distributed system. The most common occurrence is an asymmetric one: a client sends requests to a server,
and the server responds. This is a client-server system.
If both components are equivalent, both able to initiate and to respond to messages, then we have a
peer-to-peer system. Note that this is a logical classification: one peer may be a 16,000 core supercomputer,
the other might be a mobile phone. But if both can act similarly, then they are peers.
These are illustrated as shown in Figure 1-6.

client-server A B

peer-to-peer A A’

Figure 1-6. Client-sever versus peer-to-peer systems

7
Chapter 1 ■ Architecture

Client-Server System
Another view of a client-server system is shown in Figure 1-7.

User Client Server


request
Client Server
process process
response
System System

hardware hardware

Figure 1-7. The client-server system

This view may be held by a developer who needs to know the components of a system. It is also the view
that may be held by a user: a user of a browser knows it is running on her system but is communicating with
servers elsewhere.

Client-Server Application
Some applications may be seamlessly distributed, with the user unaware that it is distributed. Users will see
their view of the system, as shown in Figure 1-8.

Client Server

Client Application
process Process

System System

hardware hardware

Figure 1-8. The user’s view of the system

8
Chapter 1 ■ Architecture

Server Distribution
A client-server system need not be simple. The basic model is a single client, single server system, as shown
in Figure 1-9.

Client Server

Figure 1-9. The single client, single server system

However, you can also have multiple clients, single server, as illustrated in Figure 1-10.

Client Master Client

Slave Slave

Figure 1-10. The multiple clients, single server system

In this system, the master receives requests and instead of handling them one at a time itself, it passes
them to other servers to handle. This is a common model when concurrent clients are possible.
There are also single client, multiple servers, as shown in Figure 1-11.

Client Server Server

Figure 1-11. The single client, multiple servers system

This type of system occurs frequently when a server needs to act as a client to other servers, such as
a business logic server getting information from a database server. And of course, there could be multiple
clients with multiple servers.

Communication Flows
The previous diagrams have shown the connection views between high-level components of a system. Data
will flow between these components and it can do so in multiple ways, discussed in the following sections.

9
Chapter 1 ■ Architecture

Synchronous Communication
In a synchronous communication, one party will send a message and block, waiting for a reply. This is often
the simplest model to implement and is just relies on blocking I/O. However, there may need to be a timeout
mechanism in case some error means that no reply will ever be sent.

Asynchronous Communication
In asynchronous communication, one party sends a message and instead of waiting for a reply carries
on with other work. When a reply eventually comes, it is handled. This may be in another thread or by
interrupting the current thread. Such applications are harder to build but are much more flexible to use.

Streaming Communication
In streaming communication, one party sends a continuous stream of messages. Online video is a good
example. The streaming may need to be handled in real time, may or may not tolerate losses, and can be
one-way or allow reverse communication as in control messages.

Publish/Subscribe
In pub/sub systems, parties subscribe to topics and others post to them. This can be on a small or massive
scale, as demonstrated by Twitter.

Component Distribution
A simple but effective way of decomposing many applications is to consider them as made up of three parts:
• Presentation component
• Application logic
• Data access
The presentation component is responsible for interactions with the user, both displaying data and
gathering input. It may be a modern GUI interface with buttons, lists, menus, etc., or an older command-line
style interface, asking questions and getting answers. It could also encompass wider interaction styles, such
as the interaction with physical devices such as a cash register, ATM, etc. It could also cover the interaction
with a non-human user, as in a machine-to-machine system. The details are not important at this level.
The application logic is responsible for interpreting the users’ responses, for applying business rules, for
preparing queries, and for managing responses from the third component.
The data access component is responsible for storing and retrieving data. This will often be through a
database, but not necessarily.

10
Chapter 1 ■ Architecture

Gartner Classification
Based on this threefold decomposition of applications, Gartner considered how the components might be
distributed in a client-server system. They came up with five models, shown in Figure 1-12.

presentation presentation presentation presentation presentation


logic logic
logic logic presentation
data
logic data logic
data data data data

distributed remote distributed remote distributed


data data transaction presentation presentation

Figure 1-12. Gartner’s five models

Example: Distributed Database


• Gartner classification: 1 (see Figure 1-13)

presentation

logic

data

data

Figure 1-13. Gartner example 1

Modern mobile phones make good examples of this. Due to limited memory, they may store a small
part of a database locally so that they can usually respond quickly. However, if data is required that is not
held locally, then a request may be made to a remote database for that additional data.
Google maps is another good example. All of the maps reside on Google’s servers. When one is
requested by a user, the “nearby” maps are also downloaded into a small database in the browser. When the
user moves the map a little bit, the extra bits required are already in the local store for quick response.

11
Exploring the Variety of Random
Documents with Different Content
Chaplin, Charlie, 43

Chapman, John, 312

Chatham Islands, 26

Chidley, 149

Chicago, 184

China: Great Wall of, 4;


effect of famine in, 27, 39, 129;
licentiousness in, 176, 177;
coolieism in, 177;
waking of, 189;
standards of, 189, 190;
and the Twenty-one Demands, 306;
American trade with, 308;
bureaucracy and, 324 et seq.;
development of, 365;
consortium for financing, 364 et seq., 373;
need of constructive work in, 377;
latest loan to, 377

China Sea, 139, 141

Chinese: 30, 132, 133;


gambling, 141;
music, 176;
superstition of, 186

Chosen People, 21

Christchurch, New Zealand, 109, 143

Civil War, 120

Coan, Dr. Titus Munson, cited, 215, 216

Cocoa plantations, 105

Compasses, 25
Confucius, 6

Consortium: Agreement, 370;


function of the, 381, 382, 383

Consumption, 120

Cook, Captain James, 5, 7, 18, 28, 216, 261

Coolieism, 177, 212, 343

Copra, 53, 56, 57

Coral reefs, 37

Cradle of Mankind, 21

Culture, 27

Customs, 23

Dante, 89

Darwin: quoted on South Pacific, 22, 24, 28

Davuilevu, 61, 62

Deakin, Mr. Alfred, 349

Dengue fever, 110

Desolation Gully, 112

Dewey, Professor: cited on Japanese birth rate, 343

Divorce, 254 et seq.

Draft Act: in relation to the Maories, 123

Drake, Sir Francis, 4, 7, 9

Dunedin, New Zealand, 109, 112, 113, 127


Dutch, 4, 10

East and West News Bureau: statement of on alien labor in Japan,


332, 385

Easter Islands, 25

Eastern, the, 132, 133, 136

Eden, 17, 23

Elephantiasis, 94, 95

Ellis, Havelock, quoted, 283

Emerson, 108

England, 19, 20, 22, 24.


See also Great Britain

English, 19, 20

English Corporal Correction League, 135

Episcopal See of Australia, 138

Equator: astride the, 128-142

Europe, 17, 20, 22

Europeans: 18;
effect of famine on, 27, 52

"Evening Post," Wellington, New Zealand, quoted, 358, 359

Extinction: danger of, of primitive races, 205 et seq.

Famine: effect of upon civilized nations, 27

Fan-tan, 141
Fiji: 11, 12, 13, 18, 21, 32;
relation of, to the Pacific, 52 et seq., 81, 105, 356

"Fiji Times," Manager of, quoted, 58

Fijians: 14;
characteristics of, 19, 20, 21;
study of, 52-78;
personal appearance of, 59, 60;
characteristics of, 64 et seq.;
dances of, 67;
women, 70 et seq.;
tastes of, 71 et seq.;
music and dances of, 71, 72;
schools for, 76, 84, 85, 86;
jail of the, 73;
submersion of, 223 et seq.

Filipinos: habits and customs of, 162 et seq.

Fire-walkers of Mbenga, 13

Food, 27

Formosa, 298

Four-River Group, 372

France, 100

Frenchmen, 20

Fujiyama, 35, 193

German New Guinea, 156

German Plantation Company, 89

Germans: in Samoa, 88, 89, 90

Germany, 24, 100, 389, 391


Golden Gate, 7

Governor of Samoa, 101

Great Barrier Island, 13

Great Barrier Reef, 136, 137

Great Britain: attitude of, toward Pacific possessions, 283 et seq.,


360, 361;
attitude of toward her colonies, 362

Great Wall of China, 4

Gregory, Professor, 384

Haleakala, 48

Halemaumau, 51

Hauraki Gulf, 13

Hawaii: music of, 8, 9, 16, 17, 23, 32;


aspirations of, 42;
birth-rate, 43;
assimilation in, 43;
foot-binding in, 44;
kinship, 44;
racial evanescence, 44;
dances of, 72, 105;
divorce in, 255 et seq.;
census of, 261, 317, 356

Hawaiians: 14, 20, 30;


racial purity percentage of the, 213 et seq.

"Hawaiki," by Percy Smith, cited, 26

Hearn, Lafcadio: cited on fruit of intermarriage, 263

Heasley, Inspector, 97
Heinie's, 39

Heliolithic man, 18

"Hibbert Journal," quoted on Fijian mind, 232-234

Hilo, 48

Hindus, 78

Himalaya Mountains, 22

Hong-Kong: 109, 141, 167, 169 et seq.;


slums of, 171;
poverty in, 172;
surgery in, 176;
birth-rate in, 176;
music in, 176

Honolulu: 7, 9;
our frontier in the Pacific, 30-51;
the spirit, 37 et seq., 235.
See also Hawaii

Huang-Hsu, 365

Hughes, Premier William Morris: attitude of, toward conscription,


288, 355, 359, 360

Hukuan Railway, 378

Imperial Conferences, 347 et seq.

Imperial Diet, 384

India, 17, 18, 21, 63, 117

Indians, 77

Infanticide, 216
Inouye, Count: quoted on Japanese merchants in Korea, 309

"Invention of a New Religion," by Basil Hall Chamberlain, quoted,


304, 305

Ishii-Lansing Agreement, 370, 371

Izanagi, 21

Izanami, 21

Japan: 4, 5, 7, 9;
awakening of, 28, 29, 132, 135, 282;
in relation to the Pacific problem, 297 et seq.;
foreign policies of, 299 et seq.;
race-pride of, 302;
government of, 303;
Democracy in, 305;
attitude of, toward commercialization, 306;
American trade with, 308;
in Siberia, 308;
Buddhism in, 324;
relations of, 326 et seq.;
and alien labor, 331;
foreign population statistics of, 334;
naturalization in, 337 et seq.;
science in, 341 et seq.;
in America, 342 et seq.;
birth-rate, 343;
attitude of, toward financiering China, 373, 374;
attitude of the Orient toward, 376;
and the Pacific problem, 379;
and Manchurian railways, 380

"Japan Chronicle," quoted in British educational work in Hong-


Kong, 177;
quoted on English policy, 362

"Japan: Real and Imaginary," by Sydney Greenbie, 297

Japanese: 21, 25, 30, 31;


races, 72, 94.
See also Japan

Java, 4, 22

Joan of Arc, 51

Junnosuke Inouye, 375

Kaiser, the, 104

Kamehamea, 36, 50, 215

Kaneohe, 35, 36, 51

Kapiolani, 51

Katori-maru, 192

Keats, quoted, 3

Kellerman, Annette, 148

Kiao-chau, 368

Kilauea, 8, 50

Kinglake, 24

Kinship of Pacific peoples, 20 et seq.

Kipling, 116

Knox, Secretary, 366

Kobe: business situation in, 335

Korea: 4, 298;
Japan's actions in, 309;
the case of, 317, 324, 391

Kyoto, 7
Labor: conditions in New Zealand, 6;
in Fiji, 13 et seq.;
legislation in New Zealand, 116;
indentured, 222

Lake Rotorua, 122

Lali, 71, 73, 78

Lamont, Mr. Thomas W.: 364;


negotiations with Japan by, 375;
mission of, to China, 376, 377;
statement of, 379, 380

Language, 22, 23

Lansing, Mr.: 370;


attitude of, toward loans to China, 372

Lao-Tsze, 269

Laupepa, 395

League of Nations, 358

Legend: and the Pacific, 24 et seq.

"Lending Money to China," by Sydney Greenbie, 371

Leper Island, Molokai, 8

Levuka, 75, 85

Lindsay, Vachell, 312

Little Barrier Island, 13

Logan, Colonel Robert: 101, 104;


letter of, 395

London, Charmian, 38
London, Jack, 10

Longford, Professor, "The Story of Korea," quoted, 309

Los Angeles, 30

Lost Tribes of Israel, 23

Lurline, 7, 9

Luzon, 158

Mackaye, Arthur, 36 et seq.

Magellan, 4, 9, 18

Magneta Island, 137

"Main Street," 313

Malays, 308

Manchuria, 344, 373

Mangoes, 105

Manila: 32, 141, 158 et seq.;


description of, 163 et seq., 271

Manoa Valley, 33, 34, 37

Manono, 87

Maories: 20, 23, 26;


dances of the, 72, 110, 118 et seq.;
vital statistics of, 123;
racial discrimination against, 250

Maoriland, 17

Marital contracts, 240-253


Markets, 265-278

Marquesas, 5, 26, 52

Marshall Islands, 319, 357

Martin, Alonso, 4

Mason, Mr. Gregory, 368

Mataafa, 396;
letter, 395, 396

Mbenga: mystic fire-walkers of, 13

McDuffie, Mr., 217, 218

Melanesia, 18, 19, 23, 26, 27

Melanesian-Fijians, 20, 21

Melba, Madame, 145

Melbourne, 129, 143, 144, 349

Melville, 10, 24

Message, Mr., quoted, 61

Micronesia, 23, 26, 27

Migrations, 20

"Millard's Review," 368

Mindanao, 140, 158

Mindoro, 158

Missionaries: 19;
Fijian, 65 et seq., 68, 69, 73, 121, 231, 236

Moa, 28
Moji, 191

Molokai, the leper island, 8

Molucca Sea, 139

Mongolia, 373

Monroe Doctrine, 316

Monroe Doctrine of Asia, 297 et seq., 320

Monterey, 103

Montessori Method: in Fiji, 67

Mormon missionaries, 23

"Morning Herald," Sydney, quoted on America's War policy, 350,


351

Morocco, 390

Mt. Eden, 110

Mount Vaea, 103

Mua Peak, 87

Mulinuu, 91

Mummy-apples, 20, 59

Nagasaki, 376

Napier, New Zealand, 276

Napoleon: 20;
in relation to Fijian legend, 21

Negros, 158
New South Wales, 146

New York, 111, 113, 184, 270, 364

"New York Times," on Japanese, 311

New Zealand: labor conditions in, 6, 13, 14, 17, 20, 23, 26, 72,
84, 105;
study of, 108-127;
home life in, 111;
the bush of, 111;
farmers, 112 et seq.;
newspapers, 113;
population, 113;
characteristics, 114, 115;
girls, 115;
progressiveness, 116;
development, 117 et seq.;
Parliament, in relation to the Draft Act, 123, 133, 145;
and the class system, 286 et seq.;
policy toward England, 353

Niagara, the, 9, 10, 11, 16, 53, 62, 79, 86, 111

Nichi Nichi Shummun, 309, note

Nicholas of Russia, 361

Night-blooming cereus, 33

Niuafoou, 12, 13

North Island, 112

Oahu: 40;
College, 63

O'Brien, Frederick, 10, 24

One hundred and eightieth meridian, 11, 13, 195


Open Door, 367, 369, 371

Origins of races, 22

"Osaka Asahi," 360

"Outlines of History," Wells, 29

Pacific: discovery of, 3 et seq.;


significance of, 7;
effect of the mid-, on time, 11;
kinship of Pacific peoples, 20 et seq.;
Darwin quoted on South, 22;
origin of, cultures, 23;
Griffith Taylor quoted on size of, 24;
counter-invasion of, 28 et seq.;
our frontier in the, 30 et seq.;
relation of Fiji to the, 52;
outposts of the white man in the far, 143 et seq.;
our peg in the far, 158-167;
ideals that dwell around the, 199-201;
Hindu problems and the, 225;
political problems of the, 281 et seq.;
adventures of America in the, 317 et seq.;
causes of confusion obtaining in the, 386, 387

Pago Pago, 10, 82, 317

Paleolithic life, 16

Pali, the, 35, 37, 50

Panama Canal, 315

Panama-Pacific Exposition, 79

Panay, 158

Pan-Pacific Union, 236

Papuans, 53
Pasig River, 161

"Paul and Virginia," 137

Pavlova, 46

Peace Conference, 357, 358, 371

Peace Treaty, 358

Persia, 390

Pescadores, 357

Pharaohs, 25

Philippines: 6, 32, 140, 317;


problem of the, 318 et seq.;
and independence, 328

Pilgrims, 17

Pleistonic period, 20

Polyandry, 220

Polynesia: 17, 18, 23, 27;


present status of, 29

Polynesians: 19;
origin of the, 20, 23, 24, 25, 28, 52;
dances of the, 72, 88, 206;
character of the ancient, 215;
and the problem of intermarriage, 237 et seq.

Population: limitation of, 27, 28;


decline of, 30 et seq.

Port Chalmers, 129

Port Williamson, 132

Portuguese, 4, 30
Poverty Bay, 28

Prisoners: Fiji, 73, 74

Promotion Committee: of Honolulu, 34;


"Primer" of the, 41

Queensland, 138, 146

Race-blending, 28 et seq.

Rangatora, 120, 121

Rarotanga, 93

Ratu Joni, 230

Reading, Lord: on loans, 372

Reinsch, Dr. Paul S., 326, 327

Rewa River, Fiji, 18, 19, 60, 62, 67

Rickshaws, 171, 178

Rockefeller Foundation, 173, 174, 324

Rolland, 108

Roosevelt, Colonel, and Korea, 318

Root-Takahira Agreement, quoted, 369, 370

Rua, Maori priest, 127

Russia, 308, 391

Russo-Japanese War, 317, 348, 365

Ryecroft, Reverend Mr., 65 et seq., 68


Salvation Army, 44, 45, 179

Samoa: 10, 11, 13, 19;


cosmogony, 21, 23, 26, 52, 84, 238, 317, 356

Samoans: 14;
dances of the, 72;
study of the, 79 et seq.;
songs of the, 80;
dances of the, 83;
hospitality of the, 93 et seq., 208

Samurai, 305

San Francisco, 7, 10, 184

Santa Anna Valley, 137

Savii, 26, 87

Scientific, 236

Scientists, 231

Seattle, 193

Sedan chairs, 171

Shackleton, Sir E., 128

Shanghai: China's European capital, 179-191;


description of, 192 et seq.;
slums of, 185;
the Chinese city, 185 et seq.;
market, 274

Shantung: 297;
rape of, 324

Shaw, 108
Shibusawa, 375

Shimonoseki, 376

Shintoism: 299;
defined, 304, 305

Shurman, Dr. Jacob Gould, 327

Siberia, 344

Siberian Railway, 361

Sikhs, 231

Sino-Japanese Military Agreement, 380

Sino-Japanese War, 365

Slums: tropical, 165;


Hong-Kong, 171

Smith, Percy, cited, 26

Smythe, Miss: 179;


work of, 180-182

Solomon Islands, 65

"Son of the Middle Border," 313

South Manchurian Railway, 375, 380

South Pole, 128

South Seas: 5 et seq., 10, 12 et seq., 14, 30 et seq.;


style, 32, 57, 74, 80, 82

Spanish, 10

Sponges, 37

St. Helena, 20
Stevenson, R. L.: 10, 88, 100;
pilgrimage to tomb of, 100-105;
home of, 103, 387, 395

Stevenson Fellowship, 395

Stewart, Mr. W. Downie: quoted on status of New Zealand, 359

Stone Age, 89

Street, Julian, 375

Sulu Sea, 139

Sulus, 65

Sun Yat-sen, Dr., 325;


quoted, 326

Superstition, 25

Suva, Fiji, 11, 13, 20, 55, 56, 57, 58, 61, 73, 75, 76, 84, 105

Sydney, 9, 12, 132, 139, 146 et seq.

Tagalog, 165

Tagore: 116;
experiences of in Japan, 311

Tahiti, 17, 26, 28, 52

Talume, 12

Tamasese, 395

Tamba Maru, 179

Tasman, 9, 10

Tasman Sea, 128


Tasmania, 132

Tattooings of Time, 17

Taylor, Griffith: quoted on size of Pacific, 24

Te Noroto, 124

Terauchi, Count, 368

Thomson, Basil, cited, 13

Thursday Island, 155

"Times," China: quoted on foreign control of industries, 378

Thoreau, 95

Tokyo, 349

Tolstoy, 269

Tongans, 19, 77

Torres Straits, 139

Townsville, 137

Traders: in the Far East, 55, 89, 236, 306

Tradition, 22

Tulane, 13

Turks, 20

Tusitala, the tale teller (Stevenson), 103, 395

Typee, 5

Typhoons, 141
Uchida, Viscount: quoted on Consortium, 379, 384

Union Steamship Company, 129

Upolu, 87

Vailima, Stevenson's home, 88, 100, 101, 103

Vancouver, George, 5, 7, 18

Venice of the Pacific, 25

Vice: among the primitive races, 217

Victoria, 146

Vikings, 25

Virginia, 151

Vladivostok, 308

Waikato, 124

Waikiki, 39

Waitemata Harbor, 13

Ward, Sir Joseph, 349, 351

Waterhouse, Mr., 69

Waterspouts, 140

Webb, Mr., 245

Wellington: 97, 109, 113;


Museum, 235

Wellington, Duke of: cited on Britain's colonies, 283


Wells, H. G., 29

"When the Sleeper Wakes," Wells, 29

White Australia policy, 291, 292, 294, 348, 350

Whitney, Judge William L., 256-258

Wilson Administration, 318

Wilson, President, 382, 383

Wimmera, 131

World War, 234, 350

"World's Work," 371

Wright, Mr., of the "Bulletin," 38 et seq.

Wurm ice age, 26

Yamada Ise, 192

Yokohama, 192

Y. M. C. A., 38

Zamboanga, 140, 158


*** END OF THE PROJECT GUTENBERG EBOOK THE PACIFIC
TRIANGLE ***

Updated editions will replace the previous one—the old editions will
be renamed.

Creating the works from print editions not protected by U.S.


copyright law means that no one owns a United States copyright in
these works, so the Foundation (and you!) can copy and distribute it
in the United States without permission and without paying
copyright royalties. Special rules, set forth in the General Terms of
Use part of this license, apply to copying and distributing Project
Gutenberg™ electronic works to protect the PROJECT GUTENBERG™
concept and trademark. Project Gutenberg is a registered trademark,
and may not be used if you charge for an eBook, except by following
the terms of the trademark license, including paying royalties for use
of the Project Gutenberg trademark. If you do not charge anything
for copies of this eBook, complying with the trademark license is
very easy. You may use this eBook for nearly any purpose such as
creation of derivative works, reports, performances and research.
Project Gutenberg eBooks may be modified and printed and given
away—you may do practically ANYTHING in the United States with
eBooks not protected by U.S. copyright law. Redistribution is subject
to the trademark license, especially commercial redistribution.

START: FULL LICENSE


THE FULL PROJECT GUTENBERG LICENSE
PLEASE READ THIS BEFORE YOU DISTRIBUTE OR USE THIS WORK

To protect the Project Gutenberg™ mission of promoting the free


distribution of electronic works, by using or distributing this work (or
any other work associated in any way with the phrase “Project
Gutenberg”), you agree to comply with all the terms of the Full
Project Gutenberg™ License available with this file or online at
www.gutenberg.org/license.

Section 1. General Terms of Use and


Redistributing Project Gutenberg™
electronic works
1.A. By reading or using any part of this Project Gutenberg™
electronic work, you indicate that you have read, understand, agree
to and accept all the terms of this license and intellectual property
(trademark/copyright) agreement. If you do not agree to abide by all
the terms of this agreement, you must cease using and return or
destroy all copies of Project Gutenberg™ electronic works in your
possession. If you paid a fee for obtaining a copy of or access to a
Project Gutenberg™ electronic work and you do not agree to be
bound by the terms of this agreement, you may obtain a refund
from the person or entity to whom you paid the fee as set forth in
paragraph 1.E.8.

1.B. “Project Gutenberg” is a registered trademark. It may only be


used on or associated in any way with an electronic work by people
who agree to be bound by the terms of this agreement. There are a
few things that you can do with most Project Gutenberg™ electronic
works even without complying with the full terms of this agreement.
See paragraph 1.C below. There are a lot of things you can do with
Project Gutenberg™ electronic works if you follow the terms of this
agreement and help preserve free future access to Project
Gutenberg™ electronic works. See paragraph 1.E below.
1.C. The Project Gutenberg Literary Archive Foundation (“the
Foundation” or PGLAF), owns a compilation copyright in the
collection of Project Gutenberg™ electronic works. Nearly all the
individual works in the collection are in the public domain in the
United States. If an individual work is unprotected by copyright law
in the United States and you are located in the United States, we do
not claim a right to prevent you from copying, distributing,
performing, displaying or creating derivative works based on the
work as long as all references to Project Gutenberg are removed. Of
course, we hope that you will support the Project Gutenberg™
mission of promoting free access to electronic works by freely
sharing Project Gutenberg™ works in compliance with the terms of
this agreement for keeping the Project Gutenberg™ name associated
with the work. You can easily comply with the terms of this
agreement by keeping this work in the same format with its attached
full Project Gutenberg™ License when you share it without charge
with others.

1.D. The copyright laws of the place where you are located also
govern what you can do with this work. Copyright laws in most
countries are in a constant state of change. If you are outside the
United States, check the laws of your country in addition to the
terms of this agreement before downloading, copying, displaying,
performing, distributing or creating derivative works based on this
work or any other Project Gutenberg™ work. The Foundation makes
no representations concerning the copyright status of any work in
any country other than the United States.

1.E. Unless you have removed all references to Project Gutenberg:

1.E.1. The following sentence, with active links to, or other


immediate access to, the full Project Gutenberg™ License must
appear prominently whenever any copy of a Project Gutenberg™
work (any work on which the phrase “Project Gutenberg” appears,
or with which the phrase “Project Gutenberg” is associated) is
accessed, displayed, performed, viewed, copied or distributed:
This eBook is for the use of anyone anywhere in the United
States and most other parts of the world at no cost and with
almost no restrictions whatsoever. You may copy it, give it away
or re-use it under the terms of the Project Gutenberg License
included with this eBook or online at www.gutenberg.org. If you
are not located in the United States, you will have to check the
laws of the country where you are located before using this
eBook.

1.E.2. If an individual Project Gutenberg™ electronic work is derived


from texts not protected by U.S. copyright law (does not contain a
notice indicating that it is posted with permission of the copyright
holder), the work can be copied and distributed to anyone in the
United States without paying any fees or charges. If you are
redistributing or providing access to a work with the phrase “Project
Gutenberg” associated with or appearing on the work, you must
comply either with the requirements of paragraphs 1.E.1 through
1.E.7 or obtain permission for the use of the work and the Project
Gutenberg™ trademark as set forth in paragraphs 1.E.8 or 1.E.9.

1.E.3. If an individual Project Gutenberg™ electronic work is posted


with the permission of the copyright holder, your use and distribution
must comply with both paragraphs 1.E.1 through 1.E.7 and any
additional terms imposed by the copyright holder. Additional terms
will be linked to the Project Gutenberg™ License for all works posted
with the permission of the copyright holder found at the beginning
of this work.

1.E.4. Do not unlink or detach or remove the full Project


Gutenberg™ License terms from this work, or any files containing a
part of this work or any other work associated with Project
Gutenberg™.

1.E.5. Do not copy, display, perform, distribute or redistribute this


electronic work, or any part of this electronic work, without
prominently displaying the sentence set forth in paragraph 1.E.1
with active links or immediate access to the full terms of the Project
Gutenberg™ License.

1.E.6. You may convert to and distribute this work in any binary,
compressed, marked up, nonproprietary or proprietary form,
including any word processing or hypertext form. However, if you
provide access to or distribute copies of a Project Gutenberg™ work
in a format other than “Plain Vanilla ASCII” or other format used in
the official version posted on the official Project Gutenberg™ website
(www.gutenberg.org), you must, at no additional cost, fee or
expense to the user, provide a copy, a means of exporting a copy, or
a means of obtaining a copy upon request, of the work in its original
“Plain Vanilla ASCII” or other form. Any alternate format must
include the full Project Gutenberg™ License as specified in
paragraph 1.E.1.

1.E.7. Do not charge a fee for access to, viewing, displaying,


performing, copying or distributing any Project Gutenberg™ works
unless you comply with paragraph 1.E.8 or 1.E.9.

1.E.8. You may charge a reasonable fee for copies of or providing


access to or distributing Project Gutenberg™ electronic works
provided that:

• You pay a royalty fee of 20% of the gross profits you derive
from the use of Project Gutenberg™ works calculated using the
method you already use to calculate your applicable taxes. The
fee is owed to the owner of the Project Gutenberg™ trademark,
but he has agreed to donate royalties under this paragraph to
the Project Gutenberg Literary Archive Foundation. Royalty
payments must be paid within 60 days following each date on
which you prepare (or are legally required to prepare) your
periodic tax returns. Royalty payments should be clearly marked
as such and sent to the Project Gutenberg Literary Archive
Foundation at the address specified in Section 4, “Information
about donations to the Project Gutenberg Literary Archive
Foundation.”

• You provide a full refund of any money paid by a user who


notifies you in writing (or by e-mail) within 30 days of receipt
that s/he does not agree to the terms of the full Project
Gutenberg™ License. You must require such a user to return or
destroy all copies of the works possessed in a physical medium
and discontinue all use of and all access to other copies of
Project Gutenberg™ works.

• You provide, in accordance with paragraph 1.F.3, a full refund of


any money paid for a work or a replacement copy, if a defect in
the electronic work is discovered and reported to you within 90
days of receipt of the work.

• You comply with all other terms of this agreement for free
distribution of Project Gutenberg™ works.

1.E.9. If you wish to charge a fee or distribute a Project Gutenberg™


electronic work or group of works on different terms than are set
forth in this agreement, you must obtain permission in writing from
the Project Gutenberg Literary Archive Foundation, the manager of
the Project Gutenberg™ trademark. Contact the Foundation as set
forth in Section 3 below.

1.F.

1.F.1. Project Gutenberg volunteers and employees expend


considerable effort to identify, do copyright research on, transcribe
and proofread works not protected by U.S. copyright law in creating
the Project Gutenberg™ collection. Despite these efforts, Project
Gutenberg™ electronic works, and the medium on which they may
be stored, may contain “Defects,” such as, but not limited to,
incomplete, inaccurate or corrupt data, transcription errors, a
copyright or other intellectual property infringement, a defective or
damaged disk or other medium, a computer virus, or computer
codes that damage or cannot be read by your equipment.

1.F.2. LIMITED WARRANTY, DISCLAIMER OF DAMAGES - Except for


the “Right of Replacement or Refund” described in paragraph 1.F.3,
the Project Gutenberg Literary Archive Foundation, the owner of the
Project Gutenberg™ trademark, and any other party distributing a
Project Gutenberg™ electronic work under this agreement, disclaim
all liability to you for damages, costs and expenses, including legal
fees. YOU AGREE THAT YOU HAVE NO REMEDIES FOR
NEGLIGENCE, STRICT LIABILITY, BREACH OF WARRANTY OR
BREACH OF CONTRACT EXCEPT THOSE PROVIDED IN PARAGRAPH
1.F.3. YOU AGREE THAT THE FOUNDATION, THE TRADEMARK
OWNER, AND ANY DISTRIBUTOR UNDER THIS AGREEMENT WILL
NOT BE LIABLE TO YOU FOR ACTUAL, DIRECT, INDIRECT,
CONSEQUENTIAL, PUNITIVE OR INCIDENTAL DAMAGES EVEN IF
YOU GIVE NOTICE OF THE POSSIBILITY OF SUCH DAMAGE.

1.F.3. LIMITED RIGHT OF REPLACEMENT OR REFUND - If you


discover a defect in this electronic work within 90 days of receiving
it, you can receive a refund of the money (if any) you paid for it by
sending a written explanation to the person you received the work
from. If you received the work on a physical medium, you must
return the medium with your written explanation. The person or
entity that provided you with the defective work may elect to provide
a replacement copy in lieu of a refund. If you received the work
electronically, the person or entity providing it to you may choose to
give you a second opportunity to receive the work electronically in
lieu of a refund. If the second copy is also defective, you may
demand a refund in writing without further opportunities to fix the
problem.

1.F.4. Except for the limited right of replacement or refund set forth
in paragraph 1.F.3, this work is provided to you ‘AS-IS’, WITH NO
OTHER WARRANTIES OF ANY KIND, EXPRESS OR IMPLIED,
INCLUDING BUT NOT LIMITED TO WARRANTIES OF
MERCHANTABILITY OR FITNESS FOR ANY PURPOSE.

1.F.5. Some states do not allow disclaimers of certain implied


warranties or the exclusion or limitation of certain types of damages.
If any disclaimer or limitation set forth in this agreement violates the
law of the state applicable to this agreement, the agreement shall be
interpreted to make the maximum disclaimer or limitation permitted
by the applicable state law. The invalidity or unenforceability of any
provision of this agreement shall not void the remaining provisions.

1.F.6. INDEMNITY - You agree to indemnify and hold the Foundation,


the trademark owner, any agent or employee of the Foundation,
anyone providing copies of Project Gutenberg™ electronic works in
accordance with this agreement, and any volunteers associated with
the production, promotion and distribution of Project Gutenberg™
electronic works, harmless from all liability, costs and expenses,
including legal fees, that arise directly or indirectly from any of the
following which you do or cause to occur: (a) distribution of this or
any Project Gutenberg™ work, (b) alteration, modification, or
additions or deletions to any Project Gutenberg™ work, and (c) any
Defect you cause.

Section 2. Information about the Mission


of Project Gutenberg™
Project Gutenberg™ is synonymous with the free distribution of
electronic works in formats readable by the widest variety of
computers including obsolete, old, middle-aged and new computers.
It exists because of the efforts of hundreds of volunteers and
donations from people in all walks of life.

Volunteers and financial support to provide volunteers with the


assistance they need are critical to reaching Project Gutenberg™’s
goals and ensuring that the Project Gutenberg™ collection will
remain freely available for generations to come. In 2001, the Project
Gutenberg Literary Archive Foundation was created to provide a
secure and permanent future for Project Gutenberg™ and future
generations. To learn more about the Project Gutenberg Literary
Archive Foundation and how your efforts and donations can help,
see Sections 3 and 4 and the Foundation information page at
www.gutenberg.org.

Section 3. Information about the Project


Gutenberg Literary Archive Foundation
The Project Gutenberg Literary Archive Foundation is a non-profit
501(c)(3) educational corporation organized under the laws of the
state of Mississippi and granted tax exempt status by the Internal
Revenue Service. The Foundation’s EIN or federal tax identification
number is 64-6221541. Contributions to the Project Gutenberg
Literary Archive Foundation are tax deductible to the full extent
permitted by U.S. federal laws and your state’s laws.

The Foundation’s business office is located at 809 North 1500 West,


Salt Lake City, UT 84116, (801) 596-1887. Email contact links and up
to date contact information can be found at the Foundation’s website
and official page at www.gutenberg.org/contact

Section 4. Information about Donations to


the Project Gutenberg Literary Archive
Foundation
Project Gutenberg™ depends upon and cannot survive without
widespread public support and donations to carry out its mission of
increasing the number of public domain and licensed works that can
be freely distributed in machine-readable form accessible by the
widest array of equipment including outdated equipment. Many
small donations ($1 to $5,000) are particularly important to
maintaining tax exempt status with the IRS.

The Foundation is committed to complying with the laws regulating


charities and charitable donations in all 50 states of the United
States. Compliance requirements are not uniform and it takes a
considerable effort, much paperwork and many fees to meet and
keep up with these requirements. We do not solicit donations in
locations where we have not received written confirmation of
compliance. To SEND DONATIONS or determine the status of
compliance for any particular state visit www.gutenberg.org/donate.

While we cannot and do not solicit contributions from states where


we have not met the solicitation requirements, we know of no
prohibition against accepting unsolicited donations from donors in
such states who approach us with offers to donate.

International donations are gratefully accepted, but we cannot make


any statements concerning tax treatment of donations received from
outside the United States. U.S. laws alone swamp our small staff.

Please check the Project Gutenberg web pages for current donation
methods and addresses. Donations are accepted in a number of
other ways including checks, online payments and credit card
donations. To donate, please visit: www.gutenberg.org/donate.

Section 5. General Information About


Project Gutenberg™ electronic works
Professor Michael S. Hart was the originator of the Project
Gutenberg™ concept of a library of electronic works that could be
freely shared with anyone. For forty years, he produced and
distributed Project Gutenberg™ eBooks with only a loose network of
volunteer support.
Project Gutenberg™ eBooks are often created from several printed
editions, all of which are confirmed as not protected by copyright in
the U.S. unless a copyright notice is included. Thus, we do not
necessarily keep eBooks in compliance with any particular paper
edition.

Most people start at our website which has the main PG search
facility: www.gutenberg.org.

This website includes information about Project Gutenberg™,


including how to make donations to the Project Gutenberg Literary
Archive Foundation, how to help produce our new eBooks, and how
to subscribe to our email newsletter to hear about new eBooks.
Welcome to our website – the ideal destination for book lovers and
knowledge seekers. With a mission to inspire endlessly, we offer a
vast collection of books, ranging from classic literary works to
specialized publications, self-development books, and children's
literature. Each book is a new journey of discovery, expanding
knowledge and enriching the soul of the reade

Our website is not just a platform for buying books, but a bridge
connecting readers to the timeless values of culture and wisdom. With
an elegant, user-friendly interface and an intelligent search system,
we are committed to providing a quick and convenient shopping
experience. Additionally, our special promotions and home delivery
services ensure that you save time and fully enjoy the joy of reading.

Let us accompany you on the journey of exploring knowledge and


personal growth!

textbookfull.com

You might also like