Implementing a Messaging Protocol
Weâve just explored how to create socket servers that listen for incoming connections in Node. So far, our example programs have sent plain-text messages that are meant to be read by a human. In this section, weâll design and implement a better protocol.
A protocol is a set of rules that defines how endpoints in a system communicate. Any time you develop a networked application in Node, youâre working with one or more protocols. Here weâll create a protocol based on passing JSON encoded messages over TCP.[13]
JSON is incredibly prevalent in Node.js programming and in JavaScript programming generally. Weâll use it extensively for data serialization and configuration throughout the book. JSON is significantly ...
Get Node.js the Right Way now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.