0
0
mirror of https://github.com/nodejs/node.git synced 2024-11-25 08:19:38 +01:00
nodejs/tcp_example.js

28 lines
481 B
JavaScript
Raw Normal View History

client = new TCPClient("google.com", 80);
2009-03-05 13:41:10 +01:00
log("readyState: " + client.readyState);
//assertEqual(client.readystate, TCP.CONNECTING);
client.onopen = function () {
log("connected to google");
2009-03-05 13:41:10 +01:00
log("readyState: " + client.readyState);
client.write("GET / HTTP/1.1\r\n\r\n");
2009-03-05 13:41:10 +01:00
};
client.onread = function (chunk) {
log(chunk);
};
client.onclose = function () {
log("connection closed");
};
2009-03-05 13:41:10 +01:00
setTimeout(function () {
client.disconnect();
}, 10 * 1000);
log("hello");