return process;
};
+node.tcp.createConnection = function (port, host) {
+ var connection = new node.tcp.Connection();
+ connection.connect(port, host);
+ return connection;
+};
+
// Timers
function setTimeout (callback, after) {
}).listen(port);
- var c = new node.tcp.Connection();
+ var c = node.tcp.createConnection(port);
+
c.setEncoding("utf8");
+
c.addListener("connect", function () {
c.send( "GET /hello HTTP/1.1\r\n\r\n" );
requests_sent += 1;
c.addListener("disconnect", function () {
assertEquals(c.readyState, "closed");
});
-
- c.connect(port);
}
function onExit () {
});
});
server.listen(port);
- var client = new node.tcp.Connection();
+
+ var client = node.tcp.createConnection(port);
client.setEncoding("UTF8");
+
client.addListener("connect", function () {
+ puts("client connected.");
});
client.addListener("receive", function (chunk) {
else
server.close();
});
-
- client.connect(port);
}
function onExit () {
});
server.listen(port, host);
- var client = new node.tcp.Connection();
- assertEquals("closed", client.readyState);
+ var client = node.tcp.createConnection(port, host);
client.setEncoding("utf8");
if (on_complete) on_complete();
tests_run += 1;
});
-
- assertEquals("closed", client.readyState);
- client.connect(port, host);
}
function onLoad () {
(TODO: access error codes.)
|=========================================================
-+new node.tcp.Connection()+::
- Creates a new connection object.
-
-
-+connection.connect(port, host="127.0.0.1")+::
- Opens a connection to the specified +port+ and
++node.tcp.createConnection(port, host="127.0.0.1")+::
+ Creates a new connection object and
+ opens a connection to the specified +port+ and
+host+. If the second parameter is omitted, localhost is
assumed.