0
0
mirror of https://github.com/nodejs/node.git synced 2024-11-24 12:10:08 +01:00
nodejs/tcp_example.js

28 lines
481 B
JavaScript

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