]>
Commit | Line | Data |
---|---|---|
7c673cae FG |
1 | |
2 | var HOST = 'localhost'; | |
3 | var PORT = 80; | |
4 | var EXIT_TIMEOUT = 300e3; | |
5 | ||
6 | print('automatic exit after ' + (EXIT_TIMEOUT / 1e3) + ' seconds'); | |
7 | setTimeout(function () { | |
8 | print('exit timer'); | |
9 | EventLoop.requestExit(); | |
10 | }, EXIT_TIMEOUT); | |
11 | ||
12 | EventLoop.connect(HOST, PORT, function (fd) { | |
13 | print('connected to ' + HOST + ':' + PORT + ', fd', fd); | |
14 | EventLoop.setReader(fd, function (fd, data) { | |
15 | print('read from fd', fd); | |
16 | print(data); | |
17 | EventLoop.close(fd); | |
18 | }); | |
19 | EventLoop.write(fd, "GET / HTTP/1.1\r\n" + | |
20 | "Host: " + HOST + "\r\n" + | |
21 | "User-Agent: client-socket-test.js\r\n" + | |
22 | "\r\n"); | |
23 | }); | |
24 |