Introduction to Node.js(1)
Introduction to Node.js(1)
- by Poechant (blog.csdn.net/poechant)
1 Hello World
$ sudo port install nodejs
$ echo "console.log(\"Hello World\");" > helloword.js
$ node helloworld.js
2 A simple TCP server
Create a file named “simple_tcp_server.js”
require("net").createServer(function(socket) {
socket.write('Echo server\r\n');
socket.pipe(socket);
}).listen(8765, "127.0.0.1");
Run your server:
$ node simple_tcp_server.js
3 A simple HTTP server
Create a file named “simple_http_server.js”
require("http").createServer(function(request, response) {
console.log("Hello World");
response.writeHead(200, {"Content-Type": "text/plain"});
response.write("Hello World\n");
response.end();
}).listen(8765, "127.0.0.1");
-
轉載請註明來自柳大的CSDN部落格:blog.csdn.net/poechant
-
相關文章
- Introduction to Node.js(2)Node.js
- Chapter 1:IntroductionAPT
- 1 Introduction to the Multitenant ArchitectureNaN
- Entity Framework 6.0 Tutorials(1):IntroductionFramework
- Entity Framework Tutorial Basics(1):IntroductionFramework
- Entity Framework Code-First(1):IntroductionFramework
- [Java] Introduction to Java Programming 筆記: Chapter 1. 概念Java筆記APT
- (1) Introduction to SQL*Net/Net8 on UNIX [ID 16652.1]SQL
- MIT6.S081 - Lecture1: Introduction and ExamplesMIT
- Introduction to AlgorithmGo
- Introduction to GitGit
- TLS 1.3 IntroductionTLS
- nodejs introductionNodeJS
- Introduction to Partitioning
- No Sql Db IntroductionSQL
- Hadoop IntroductionHadoop
- Introduction to Databases and MySQLDatabaseMySql
- Oracle RAC introductionOracle
- 《Pattern Recognition and Machine Learning》第一章1. INTRODUCTIONMac
- 6-1 Node.js 模組Node.js
- Introduction of DataGuard protection mode
- A re-introduction to JavaScriptJavaScript
- [zz]android introductionAndroid
- Introduction to Index Segments (24)Index
- Node.js學習筆記1Node.js筆記
- <node.js學習筆記(1)>Node.js筆記
- Aizu Online Judge Introduction to Programming I C語言實現 ITP1 Topic # 1AIC語言
- Machine Learning-IntroductionMac
- A gentle introduction to multithreadingthread
- Introduction to ASP.NET 5ASP.NET
- An Introduction to the Basics of Modern CSS ButtonsCSS
- Introduction to an Oracle Instance (284)Oracle
- Visitor Pattern Introduction (轉)
- Introduction to Schema Objects (153)Object
- Introduction to Oracle Memory Structures (69)OracleStruct
- HMAC: Introduction, History, and ApplicationsMacAPP
- Node.js原始碼學習(1) 使用cLion除錯node.js原始碼Node.js原始碼除錯
- node.js 1Million concurrent connections!Node.js