Get Even More Visitors To Your Blog, Upgrade To A Business Listing >>

possible web protocols in javascript

possible web protocols in javascript


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.

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?

Problem courtesy of: Bergi


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 for one list. And if you can't find a ready made module for your favorite protocol, you can implement one yourself.

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.

Solution courtesy of: Tapio


View additional discussion.

This post first appeared on Node.js Recipes, please read the originial post: here

Share the post

possible web protocols in javascript


Subscribe to Node.js Recipes

Get updates delivered right to your inbox!

Thank you for your subscription