简体   繁体   English

Node.js从任何客户端发送和接收数据包

[英]Node.js send and receive packets from any client

How a Node.js server can accept and connect to any requests even if they didn't come from clients that are connected directly to server? 即使请求不是来自直接连接到服务器的客户端,Node.js服务器如何接受并连接到任何请求?

They only way is to create an API? 他们唯一的方法就是创建一个API? I found a solution by importing the Node modules client-side like var http = require('http'); 我通过导入节点模块客户端(如var http = require('http');找到了解决方案var http = require('http'); but are those safe and optimized? 但是那些安全且经过优化的吗?

I need it to communicate with a CEF application without implementing Node.js clientside. 我需要它与CEF应用程序通信而无需实现Node.js客户端。

A lot of people are using http.createServer . 很多人正在使用http.createServer It is going to be fine for most situations. 在大多数情况下都可以。 Use it with something like Express.js and you'll have a simple, easy solution. 与Express.js之类的东西一起使用,您将获得一个简单的解决方案。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM