Writing

Network Communication

Four layers of network communication, sockets, application protocols, HTML, HTTP, and server development.

Four Layers of Network Communication

image

Understanding Sockets Deeply

  1. A network communication tool calling the OS kernel. On creation, choose TCP (“three-way handshake, four-way wave-off”) or UDP one-shot communication.

image

  1. Sockets sit below the application layer.

What the Application Layer Solves

What content you transmit, e.g.:

  • FTP transfers files;

  • SSH remote commands.

  • SMTP and POP3 email;

  • Most common: HTTP

From Plain Text to HTML

Plain text structure is poor for display; structured data helps. Wrapping text is HTML:

image

For browser interaction, add JavaScript; browsers add a JS parser.

image

Extract JS parsing—even as backend—that is Node.js.

HTTP

Hypertext Transfer Protocol; the browser is the client.

image

image

HTTP status codes: http://tool.oschina.net/commons?type=5

Server Development Work

image

  • Parse client request messages

  • Support multithreaded concurrent access

Parameter Passing

  • Query string after ? in URL