function echo (socket) { +include("/tcp.js"); +var server = createServer(function (socket) { socket.setEncoding("utf8"); socket.addListener("connect", function () { socket.send("hello\r\n"); @@ -1481,8 +1484,7 @@ on port 7000
From 095470854b48bc9f30c52a69a813945a9e908b61 Mon Sep 17 00:00:00 2001
From: Ryan Dahl
The options argument is optional. The options argument accepts the same values as the -options argument for node.tcp.Server does.
The request_listener is a function which is automatically added to the "request" event.
To use the TCP server and client one must require("/tcp.js") or +include("/tcp.js").
Here is an example of a echo server which listens for connections on port 7000
function echo (socket) { +include("/tcp.js"); +var server = createServer(function (socket) { socket.setEncoding("utf8"); socket.addListener("connect", function () { socket.send("hello\r\n"); @@ -1481,8 +1484,7 @@ on port 7000
"connection"
connection
Emitted when a new connection is made. - connection is an instance of node.tcp.Connection.
"close"
@@ -1554,9 +1556,9 @@ event.
This object is used as a TCP client and also as a server-side -socket for node.tcp.Server.