With this tutorial you can create Net Communication client-client and server-clients with Nodejs.
The net module provides an asynchronous network API for creating stream-based TCP or IPC servers (net.createServer()) and clients (net.createConnection()).
With this Tutorial you can create a Nodejs Net Server and communicate with severals Clients via Socket.
Official Documentation: NodeJS | API Net
How to execute a Net Server and two Clients and how the Server send random message to all Clients.
How to Execute a Net Server and two Clients and how a Client send random message via Server to others Clients.
You can run this project in Gitpod, a one-click online IDE for GitHub:
List of methodologies and tools used in this project for compliance with Quality Assurance Code (QAC)
- ESTlint, tool for identifying and reporting on patterns found in ECMAScript/JavaScript code.
NPM ESLint
NPM ESLint | Airbnb
In order to work with this project, your local environment must have at least the following versions:
- Nodejs Version: 13.xx
- NPM Version: 6.12.0
You have to do the following steps to be able to work with this project.
To work with this project locally it is necessary to install the NPM dependencies.
# Install npm dependencies
$npm i
You will find two demos, in the first one, the server emit messages from a "setInterval" function to all the clients subscribed by socket and in the second one a client emit with a "setInterval" function severals message to the server by socket and this is transmitted to the other clients.
To run the first demo you need to activate at least ONE Server type Emitter and ONE Client Receiver:
# Run Server for Emit Messages
$npm run start:first-demo:server-emitter
# Run Client for Receive Message
$npm run start:first-demo:client-receiver
To run the second demo you need to activate ONE Server Dispatcher, at least ONE Clients Emitter and Others Receivers:
# Run Server for Receive and Emit Messages
$npm run start:second-demo:server-dispatcher
# Run Client for Emit Messages
$npm run start:second-demo:client-emitter
# Run at least one Client for Receive Messages
$npm run start:second-demo:client-receiver
/
βββ assets π # Images Sources.
βββ src π¦ # Main App with Server and Client.
| βββ first-demo # Demo with broadcast demo server sending randoms message to all clients.
| βββ second-demo # Demo with a client sending random message via server to all other clients.
| βββ ...
βββ ...
For review and update all npm dependences of this project you need install in global npm package "npm-check-updates" npm module.
# Install and Run
$npm i -g npm-check-updates
$ncu
Created with JavaScript, lot of β€οΈ and a few βοΈ