How can I create my own protocol as well as HTTP?

1

See this code below. It creates a server with Node.js. But if I change the var http for example: var xyz = require ("xyz"), var server = xyz.createserver ... gives error.

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");
    
asked by anonymous 25.05.2017 / 08:16

1 answer

2

With much study of the fundamentals of computing.

Well, in simplicity, write on paper what you want it to do, what operations, such as message format, errors, how to deal with each situation. You'll already have a protocol.

After specified you need to implement it .

But, no! If even the most experienced programmers are not creating protocols except in case of extreme need, do not try to do this at home, or with adult supervision:)

See: In what language was HTTP written? .

    
25.05.2017 / 12:34