This article records that two requests will appear when you use node. js to request favican. ico in the project, wasting resources. After some improvement, record the process and pay attention to it later.
The Code is as follows:
Var http = require ("http ");Var server = http. createServer ();Server. on ("request"
This article mainly introduces node. socket. io broadcast messages. For more information, see socket. the io () server has a sockets attribute. The attribute value is all socket objects connected to the client. you can use the send method or emit method of this object to broadcast messages to all clients.
Io. sockets. send ("user commected );
Io. socket. emit ("login", names );
Case
');var server = Http.createserver (function (req, res) { There's a mistake here, the params is undefined. var ok = Req.params.ok; Res.writehead ($, {' Content-type ': ' Text/plain '}); Res.end (' Hello world\n ');});Server.listen (8080, ' 127.0.0.1 ');Console.log (' Server running at http://127.0.0.1:8080/');Start the service and test it in the address bar. http://127.0.0.1:8080/As expected,
This article mainly introduces how to use Node. js to operate the mysql database for addition, deletion, modification, and query. If you need more information, please read the full text. The details are as follows:
Install the mysql Module
npm install mysql
Database preparation
The IP address of the machine where mysql server is located is 192.168.0.108. to
Use forever to implement self-starting Node. js projects on Linux, and node. jsforever
It is easy to manually run the Node project on a computer, node xx. javascript is done. If you want to run the Node project in the background,
The Socket. IO instance in node. js, node. jssocket. io
1. Introduction
First Socket. IO Official Website: http://socket.io
The official website is very concise, and there is no API documentation. There is only one simple "How to use" for reference. Because Socket. IO is as simple and easy to use as the official website.
So what is Socket. IO? Socket. IO is a Web
In node. js development, the Node Supervisor is used to modify the monitoring file and automatically restart the application.
In the development or debugging of Node. when you modify a js application, you always need to press CTRL + C to terminate the program and restart the
before running. This process takes a little time, although the compilation speed from coffee to js is actually quite fast. However, this should not be a big problem. In general, require is written at the top of the file, that is, when the application is started, it is angry that all the require files are require, when require is used, coffee is compiled into js and put into the
Definition: node. js is a JavaScript running platform running on the server side using the Google V8 engineFeatures: 1. asynchronous I/O (non-blocking I/O) 2. Event-drivenWhat is asynchronous I/O (non-blocking I/O)?To understand what asynchronous I/O is (non-blocking I/O), you must first understand what I/O, what is blocking, and what is synchronous I/O (blocking
Example of using Node. js to implement RESTful API, node. jsrestful
Basic RESTful concepts
REST (Representational State Transfer) describes an architecture-style network system that first appeared in Roy Fielding's doctoral thesis in 2000. In the REST service, application status and functions can be divided into various resources. Resources are made public to the
>> in layman nodenode. JS is a JS run environment written by C + +Browser: Rendering engine + JS engineJS running environment at the back endnode. JS uses the Google V8 engine, while providing many system-level APIs (file manipulation network programming ... )node.
coexistence:
IISNode: This is a Node on your IIS Site. js runs like an application pool, which is similar to running PHP in IIS. in fact, Azure runs Node on its platform. js.
WinServ: It makes Node. js runs like a Windows service
) {console. log (error);} else {console. log (result );} // Close the database link to db. close () ;}); // mongoose findvar criteria = {title: 'emtity _ demo_title '}; // query condition var fields = {title: 1, content: 1, time: 1}; // The Field var options ={}; mongooseModel. find (criteria, fields, options, function (error, result) {if (error) {console. log (error);} else {console. log (result);} // closes the database link to db. close () ;}); // Delete the record var conditions = {username:
indicates the number of requests sent in several rounds, that is, the total number of requests is:-cNum*-rNumHowever,-r cannot be used with-t (why? You guess). eg:-r 20
-T NUM test duration refers to the time required to run a test. After timeout, the test is completed.
-F file. used to test the url path eg in the file:-f girls.txt.
-B. Ask whether to enable the benchmark (benchmark ). This parameter is not very important. If you are interested, you can continue to learn.
I will not introduce-c
understand the principle. You may ask, during programming,For primary, slaverSo many databases, we must write data to the primary node. If the primary node goes down, how should the program detect it? How can we find the new primary node?
Don't worry. mongodb has solved your questions. Mongodb provides driver support for various languages. You only need to callR
as map, reduce, and forEach, do not necessarily support all browsers. We can solve some browser compatibility issues through the front-end library. But for Node. js, You Need To Know Exactly What operations Google's V8 JavaScript Engine supports. In this way, you can directly use these built-in methods on the server to operate the set.
9. Use Nginx before
Node. js BASICS (10) use the net module and Readline module to implement Socket communication, and node. jsreadline
The socket communication of Node. js is very similar to that of C ++ and Java. Those who have learned the socket communication of these two languages can quic
memory.
Operability: Implements the Nodejs for the memory stack monitoring system.
The advantages of node. JS we have said so much, then does it have any shortcomings?
The answer is yes, or why the fire is not up.
Let's look at the downside of node. JS:
The disadvantage of node
node. JS learns to follow the flow of this book. At the end of the 7th chapter and the end of the 10th chapter, respectively, a small project to practice practiced hand. Node. JS's Introductory Learning Plan is like this. Directory: qq:1045642972 Welcome to the book and discuss node. js.node.
Introduction to Node. js open-source application framework HapiJS, node. jshapijs
1. Introduction to HapiJS
HapiJS is an open-source, Node-based. the js application framework is suitable for building applications and services. Its design goal is to allow developers to focus
The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion;
products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the
content of the page makes you feel confusing, please write us an email, we will handle the problem
within 5 days after receiving your email.
If you find any instances of plagiarism from the community, please send an email to:
info-contact@alibabacloud.com
and provide relevant evidence. A staff member will contact you within 5 working days.