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?
What is Protocol? A network protocol defines rules and conventions for communication between network devices. By adopting these rules, two devices can communicate with each other and can interchange the information.
Common Internet protocols include TCP/IP (Transmission Control Protocol/Internet Protocol), UDP/IP (User Datagram Protocol/Internet Protocol), HTTP (HyperText Transfer Protocol) and FTP (File Transfer Protocol). TCP/IP is a stream protocol. This means that a connection is negotiated between a client and a server.
Generally speaking, there are three types of protocols in networking -- communication, such as Ethernet; management, such as Simple Mail Transfer Protocol (SMTP); and security, such as Secure Shell, or SSH.
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.
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.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With