mirror of https://github.com/svaarala/duktape.git
Browse Source
Accept non-plain buffers in some examples/extras, eventloop example buffer fixespull/2110/head
Sami Vaarala
5 years ago
committed by
GitHub
16 changed files with 47 additions and 34 deletions
@ -1,23 +1,16 @@ |
|||
|
|||
var HOST = 'localhost'; |
|||
var PORT = 80; |
|||
var EXIT_TIMEOUT = 300e3; |
|||
|
|||
print('automatic exit after ' + (EXIT_TIMEOUT / 1e3) + ' seconds'); |
|||
setTimeout(function () { |
|||
print('exit timer'); |
|||
EventLoop.requestExit(); |
|||
}, EXIT_TIMEOUT); |
|||
|
|||
EventLoop.connect(HOST, PORT, function (fd) { |
|||
print('connected to ' + HOST + ':' + PORT + ', fd', fd); |
|||
EventLoop.setReader(fd, function (fd, data) { |
|||
print('read from fd', fd); |
|||
print(data); |
|||
EventLoop.close(fd); |
|||
print(new TextDecoder().decode(data)); |
|||
// Read until completion, socket is closed by server.
|
|||
}); |
|||
EventLoop.write(fd, "GET / HTTP/1.1\r\n" + |
|||
"Host: " + HOST + "\r\n" + |
|||
"User-Agent: client-socket-test.js\r\n" + |
|||
"Connection: close\r\n" + |
|||
"\r\n"); |
|||
}); |
|||
|
Loading…
Reference in new issue