Network Programming with Go Essential Skills for Using and Securing Networks [1st edition] 9781484226919, 9781484226926, 1484226917, 1484226925

Dive into key topics in network architecture and Go, such as data serialization, application level protocols, character

670 157 2MB

English Pages 274 [284] Year 2017

Report DMCA / Copyright

DOWNLOAD FILE

Polecaj historie

Network Programming with Go Essential Skills for Using and Securing Networks [1st edition]
 9781484226919, 9781484226926, 1484226917, 1484226925

Table of contents :
Contents at a Glance......Page 4
Contents......Page 5
About the Author......Page 16
About the Technical Reviewer......Page 17
Preface......Page 18
Protocol Layers......Page 19
OSI Layers......Page 20
Networking......Page 21
Packet Encapsulation......Page 22
Message Passing......Page 23
Remote Procedure Call......Page 24
Distributed Computing Models......Page 25
Client-Server Application......Page 26
Communication Flows......Page 27
Component Distribution......Page 28
Example: Distributed Database......Page 29
Example: Terminal Emulation......Page 30
Three-Tier Models......Page 31
Middleware Examples......Page 32
Continuum of Processing......Page 33
Acceptance Factors......Page 34
Scalability Transparency......Page 35
Fallacy: The Network Is Reliable......Page 36
Fallacy: There Is One Administrator......Page 37
Conclusion......Page 38
Chapter 2: Overview of the Go Language......Page 39
Structures......Page 40
Functions......Page 41
Methods......Page 42
GOPATH......Page 43
Error Values......Page 44
Conclusion......Page 45
The TCP/IP Stack......Page 46
Internet Addresses......Page 47
IPv6 Addresses......Page 48
IP Address Type......Page 49
The IPMask Type......Page 50
The IPAddr Type......Page 53
Host Lookup......Page 54
Ports......Page 55
The TCPAddr Type......Page 56
TCP Client......Page 57
A Daytime Server......Page 59
Multi-Threaded Server......Page 61
Staying Alive......Page 63
UDP Datagrams......Page 64
The Conn, PacketConn, and Listener Types......Page 66
Raw Sockets and the IPConn Type......Page 69
Conclusion......Page 72
Structured Data......Page 73
Self-Describing Data......Page 75
ASN.1......Page 76
ASN.1 Daytime Client and Server......Page 82
JSON......Page 84
A Client and Server......Page 88
The Gob Package......Page 91
A Client and Server......Page 94
Encoding Binary Data as Strings......Page 97
Protocol Buffers......Page 99
The Compiled personv3.pb.go File......Page 100
Using the Compiled Code......Page 101
Conclusion......Page 102
Protocol Design......Page 103
Version Control......Page 104
The Web......Page 105
Message Format......Page 106
Byte Format......Page 107
A Simple Example......Page 108
A Standalone Application......Page 109
The Client Side......Page 110
Protocol: Informal......Page 111
Text Protocol......Page 112
Server Code......Page 113
Client Code......Page 115
State Information......Page 117
Application State Transition Diagram......Page 119
Client State Transition Diagrams......Page 120
Server Pseudocode......Page 121
Conclusion......Page 122
Chapter 6: Managing Character Sets and Encodings......Page 123
Character Encoding......Page 124
ASCII......Page 125
Unicode......Page 127
UTF-8 Client and Server......Page 128
Little-Endian and Big-Endian......Page 129
UTF-16 Client and Server......Page 130
Unicode Gotchas......Page 132
ISO 8859 and Go......Page 133
Conclusion......Page 135
ISO Security Architecture......Page 136
Functions and Levels......Page 137
Mechanisms......Page 138
Data Integrity......Page 139
Symmetric Key Encryption......Page 141
Public Key Encryption......Page 142
X.509 Certificates......Page 144
A Basic Client......Page 147
Server Using a Self-Signed Certificate......Page 148
Conclusion......Page 151
I18n......Page 152
Response Format......Page 153
Response Format......Page 154
HTTP 1.1......Page 155
The Response Type......Page 156
The HEAD Method......Page 157
The GET Method......Page 158
Configuring HTTP Requests......Page 160
The Client Object......Page 162
Simple Proxy......Page 164
Authenticating Proxy......Page 166
HTTPS Connections by Clients......Page 168
File Server......Page 170
Handler Functions......Page 171
Bypassing the Default Multiplexer......Page 173
HTTPS......Page 174
Conclusion......Page 175
Inserting Object Values......Page 176
Using Templates......Page 177
Pipelines......Page 179
Defining Functions......Page 180
Variables......Page 182
Conditional Statements......Page 183
Conclusion......Page 188
Browser Site Diagram......Page 189
Basic Server......Page 191
The listFlashCards Function......Page 193
The Chinese Dictionary......Page 195
The Dictionary Type......Page 196
Flashcard Sets......Page 197
Fixing Accents......Page 198
The ListWords Function......Page 201
The showFlashCards Function......Page 203
Conclusion......Page 205
Chapter 11: HTML......Page 206
The Go HTML/Template Package......Page 207
Tokenizing HTML......Page 208
XHTML/HTML......Page 210
Conclusion......Page 211
Chapter 12: XML......Page 212
The Comment Type......Page 213
The Directive Type......Page 214
Unmarshalling XML......Page 216
Marshalling XML......Page 219
Conclusion......Page 220
Chapter 13: Remote Procedure Call......Page 221
Go’s RPC......Page 222
HTTP RPC Server......Page 224
HTTP RPC Client......Page 225
TCP RPC Server......Page 226
TCP RPC Client......Page 228
JSON......Page 229
JSON RPC Server......Page 230
JSON RPC Client......Page 231
Conclusion......Page 232
URIs and Resources......Page 233
Representations......Page 234
The PUT Verb......Page 235
HATEOAS......Page 236
Representing Links......Page 237
Transactions with REST......Page 238
The Richardson Maturity Model......Page 239
URLs......Page 240
The Demultiplexer (Demuxer)......Page 241
Content Negotiation......Page 242
GET /......Page 244
POST /......Page 245
The Complete Server......Page 246
Client......Page 252
Conclusion......Page 257
Chapter 15: WebSockets......Page 258
The Message Object......Page 259
The JSON Object......Page 262
The Codec Type......Page 265
WebSockets Over TLS......Page 268
WebSockets in an HTML Page......Page 270
The Gorilla Package......Page 274
Echo Server......Page 275
Echo Client......Page 276
Conclusion......Page 277
Afterword......Page 278
Index......Page 279

Citation preview