Created
October 10, 2014 10:27
-
-
Save cheng470/a77d6b37ad6a8df6ad4e to your computer and use it in GitHub Desktop.
一个服务器,它能够接受客户端的连接,并且在断开连接 前发送了一小段内容
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var net = require('net'); | |
var tcpServer = net.createServer(); | |
tcpServer.on('connection', function(client) { | |
client.write('Hi!\n'); | |
client.write('Bye!\n'); | |
client.end(); | |
}); | |
tcpServer.listen(9000); | |
// telnet 127.0.0.1 9000 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment