Socket. IO is a websocket library, including the client js and the server nodejs. Official Address: socket. io uses socket. io and nodejs to build a websocket Server
Socket. io can not only build the websocket service of the client, but also support the websocket of the nodejs server.
Next let me introduce how to install and configure nodejs.
Go to http://nodejs.org/javasdownloadto download the msifile. Always click next to install. The final file is automatically installed in the C: \ nodejs directory.
After the installation is complete, environment variables are automatically configured. If no automatic configuration is available, manually add C: \ nodejs \ in the path \.
After the installation is complete, you need to configure npm to manage the node. js module.
Install git to install npm in window.
After installing git, open gitbush. Perform the following steps:
git config --system http.sslcainfo /bin/curl-ca-bundle.crtgit clone --recursive git://github.com/isaacs/npm.gitcd npmnode cli.js install npm -gf
The first one is that there is no prompt for the settings. The second step will go to github to download npm files and progress, and the fourth step is to install npm to node. js will copy several cmd files and the mode_modules folder to the nodejs directory.
In this way, npm is configured.
If you need to install any modules, enter npm install ***.
If there is no npm or windows users can use github to download socket. io and put it into the node_modules folder. For detailed configuration, refer to: nodejs Tutorial: configure the windows directory structure of nodejs.exe.
Install socket. io in nodejs
Use the node plug-in management package and run the following command to install socket. io successfully.
npm install socket.io
An example of socket. io implementation
Client code: