1
See this code below. It creates a server with Node.js. But, if I change var http for example: var xyz = require ("xyz"), var server = xyz.createserver
... makes a mistake.
var http = require("http");
var server = http.createServer(function(request, response) {
response.writeHead(200, {"Content-Type": "text/html"});
response.write("<!DOCTYPE "html">");
response.write("<html>");
response.write("<head>");
response.write("<title>Hello World Page</title>");
response.write("</head>");
response.write("<body>");
response.write("Hello World!");
response.write("</body>");
response.write("</html>");
response.end();
});
server.listen(80);
console.log("Server is listening");
Maybe because creating a protocol is way beyond just renaming it? When you use the
require
you are "calling a file", it is as if you inform "I’m gonna need to use this library". Then you start using what it offers, which is a set of functions that someone developed and you use. When you usexyz
it doesn’t exist, so you can’t use it. If you really want to create a new protocol I believe that will take a long way to it.– Inkeliz
Thanks for your reply. I’m new to Node.js and tals. I still need to know a lot of things.
– teves-rei
There are several levels and protocol. Even, there are protocols on protocols. The TCP/IP itself (good barte of our current internet) works on 5 main layers of protocol: 1. physical layer; 2. link/jump bed (ethernet/ATM); 3. network layer (IP); 4. transport layer (TCP/UDP); 5. application layer (HTTP/FTP/SSH etc). I have personally written some protocols on HTTP (HTTP use as a base) and also had to reverse engineer an undocumented protocol (from work) that worked directly on TCP. I can answer with that if you wish
– Jefferson Quesado
In addition to my comment: when I read the title of the question, I interpreted it as being about protocols in a generic way, there was no attack on me being connected with
node.js
.– Jefferson Quesado
@teves-rei The answer solved your doubt? Do you think you can accept it? See the [tour] if you do not know how. This would help a lot to indicate that the solution was useful for you. You can also vote on any question or answer you find useful on the entire site (when you have 15 points).
– Maniero