JS Function to send data over network?

北城余情 提交于 2020-01-10 06:16:25

问题


I have been experimenting with JavaScript lately and was wondering if there was a way to send data from one computer to another on the same network. If there is, you do I use it?


回答1:


Sure there is, but you need a server for that. You cannot connect directly two computers' browsers over a network:

Computer A ---+
              |
             SERVER
              |
Computer B ---+

The server's task will then be that of passing messages from one client to the other. You'll need PHP or C# (e.G. ASP.NET) for that. This topic is very (very) broad so this must suffice as an answer.




回答2:


You can go by a simple example of windows to windows communication. Go through the following link.

copy and paste server to server.js and client to index.html.

setup:

install socket.io
install client.io   

link:

<https://www.tutorialspoint.com/socket.io/socket.io_broadcasting.htm>


来源:https://stackoverflow.com/questions/30562123/js-function-to-send-data-over-network

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!