Skip to content

πŸ“£ Execute with Net Connections in NodeJS severals Clients and Servers sendings random messages via Socket between them.

License

Notifications You must be signed in to change notification settings

JoseJPR/tutorial-nodejs-net-socket-server-clients

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 

History

13 Commits
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

Tutorial Nodejs Net Socket Server and Clients

With this tutorial you can create Net Communication client-client and server-clients with Nodejs.



πŸ”– Description

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

πŸ“Ή Video Demo

How to execute a Net Server and two Clients and how the Server send random message to all Clients.

Video

How to Execute a Net Server and two Clients and how a Client send random message via Server to others Clients.

Video

⛅️ Develop in the Cloud

You can run this project in Gitpod, a one-click online IDE for GitHub:

Open in Gitpod

πŸ“Œ Methodologies and Guidelines

List of methodologies and tools used in this project for compliance with Quality Assurance Code (QAC)

βœ… Prerequisites

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

πŸ“ How to work with this project

You have to do the following steps to be able to work with this project.

1️⃣ Install Nodejs Dependencies

To work with this project locally it is necessary to install the NPM dependencies.

# Install npm dependencies
$npm i

2️⃣ Run

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

πŸ“‚ Code scaffolding

/
β”œβ”€β”€ 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.
|   └── ...
└── ...

⛽️ Review and Update Dependences

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

License

MIT

Happy Code

Created with JavaScript, lot of ❀️ and a few β˜•οΈ

This README.md file has been written keeping in mind

About

πŸ“£ Execute with Net Connections in NodeJS severals Clients and Servers sendings random messages via Socket between them.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Sponsor this project

 

Packages

No packages published