摘要: 1. Socket.IO1.1 服务器var http = require('http');var sio = require('socket.io');var fs = require('fs');var server = http.createServer(function(req,rsp){ ... 阅读全文
posted @ 2015-11-01 16:17 S&L·chuck 阅读(438) 评论(0) 推荐(0) 编辑
摘要: 1. MongoDBvar mongo = require('mongodb');var host = '127.0.0.1';var port = mongo.Connecton.DEFAULT_PORT;var server = new mongo.Server(host,port,{auto_... 阅读全文
posted @ 2015-11-01 15:48 S&L·chuck 阅读(284) 评论(0) 推荐(0) 编辑
摘要: 1. 加密与压缩1.1 加密var crypto = require('crypto');var text = "12345678";var hasher = crypto.createHash("sha256");hasher.update(text);var msg = hasher.diges... 阅读全文
posted @ 2015-11-01 15:21 S&L·chuck 阅读(876) 评论(0) 推荐(0) 编辑
摘要: 1. 进程var net = require('net');var cluster = require('cluster');cluster.setupMaster({ exec:'child.js'});var worker = cluster.fork();var server = net.cr... 阅读全文
posted @ 2015-11-01 14:45 S&L·chuck 阅读(235) 评论(0) 推荐(0) 编辑
摘要: 1. HTTP1.1 服务器var http = require('http');var server = http.createServer(function(req,rsp){ req.on('data',function(data){ }); req.on('end',function(){ ... 阅读全文
posted @ 2015-11-01 14:24 S&L·chuck 阅读(321) 评论(0) 推荐(0) 编辑
摘要: 1. TCP和UDP1.1 TCP服务端var net = require('net');var server = net.createServer();server.on('connection',function(socket){ socket.setEncoding('utf8'); sock... 阅读全文
posted @ 2015-11-01 14:03 S&L·chuck 阅读(1195) 评论(0) 推荐(0) 编辑