javascript中可能的网络协议 [英] possible web protocols in javascript

查看:125
本文介绍了javascript中可能的网络协议的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

HTTP有哪些替代方案(根据 XMLHttpRequest )在JavaScript中建立服务器连接时?我唯一知道的是 WebSocket协议(每<​​a href =http:// www .w3.org / TR / websockets /rel =noreferrer> WebSocket )。包含相应的安全变体https和wss。

What are the alternatives to HTTP (per XMLHttpRequest) when establishing a server connection in JavaScript? The only one I know is the WebSocket protocol (per WebSocket). Their corresponding secure variants https and wss included.

是否可以选择JavaScript的任意协议?你如何与NTP,IMAP,UDP等通信 - 例如Node.js中的服务?

Would it be possible to choose an arbitrary protocol with JavaScript? How do you communicate with NTP, IMAP, UDP etc. -services for example in Node.js?

推荐答案

来自Node.js ,你几乎可以做任何事情。例如。直接支持UDP( dgram 模块,它随node.js一起提供),而npm有一个过多的东西许多其他协议的第三方模块,如SMTP,IMAP,FTP和XMPP;有关一个列表,请参阅 https://github.com/joyent/node/wiki/Modules 。如果你找不到你喜欢的协议的现成模块,你可以自己实现。

From Node.js, you can do pretty much anything. E.g. UDP is directly supported (dgram module which is shipped with node.js), and npm has a plethora of third-party modules for many other protocols, such as SMTP, IMAP, FTP and XMPP; see https://github.com/joyent/node/wiki/Modules for one list. And if you can't find a ready made module for your favorite protocol, you can implement one yourself.

现在谈到浏览器,你会受到更多限制。你列出的是我所知道的(当然不包括浏览器插件)。因此,您需要使用HTTP(S)或ws(s)连接到代理服务器,并从那里执行实际协议。

Now when it comes to browsers, you are much more limited. Those you listed are all I know (browser plugins excluded, of course). So you'd need to connect to a proxy server with HTTP(S) or ws(s) and do the actual protocol stuff from there.

这篇关于javascript中可能的网络协议的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆