You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 
 

24 lines
685 B

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);
});
EventLoop.write(fd, "GET / HTTP/1.1\r\n" +
"Host: " + HOST + "\r\n" +
"User-Agent: client-socket-test.js\r\n" +
"\r\n");
});