Socket
Overview
A socket is one endpoint of a two-way communication link between two programs running on the network. A socket is bound to a port number so that the TCP layer can identify the application that data is destined to be sent to.Prerequisite:
socket example.zipThis zip file should contain:
- Node_modules folder
- Automobile.json
- Change.html
- Change.js
- Index.html
- package-lock.json
- Server.js
Additionally, you need a dashboard for socket and its databases. Upload the dataset first into AIV, then upload the dashboard.
Steps
-
Once the dashboard is successfully uploaded, open the command prompt and navigate to the folder containing the
Server.js
file. -
Run this command:
node server.js
. -
This command will start the node server. To verify, open a browser and enter
localhost:5002
in the address bar. -
Once the screen is available, open a new tab and enter the URL
localhost:5002/change
, then hit Enter. -
To start the socket, click on the start button. You’ll notice the socket status changing to “Started”, and a Socket ID will be displayed.
-
Go back to the previous tab, and you’ll observe data refreshing. This indicates that the socket is functioning.
-
Navigate to AIV and open the socket dashboard you uploaded. You’ll see widget data updating frequently.