{"id":1119,"date":"2011-10-09T08:32:05","date_gmt":"2011-10-09T08:32:05","guid":{"rendered":"http:\/\/www.readytext.co.uk\/?p=1119"},"modified":"2013-11-28T09:01:44","modified_gmt":"2013-11-28T09:01:44","slug":"luatex-can-connect-to-networks","status":"publish","type":"post","link":"https:\/\/www.readytext.co.uk\/?p=1119","title":{"rendered":"LuaTeX can connect to networks"},"content":{"rendered":"<p>One feature of LuaTeX which might prove useful in some circumstances is its ability to connect to networks through TCP\/IP. This facility is due to the <a href=\"http:\/\/w3.impa.br\/~diego\/software\/luasocket\/\">luasocket TCP\/IP networking<\/a> library which is built into the executable. In addition to the low-level TCP\/IP facilities, luasocket provides a number of support modules which make the following tasks quite easy to do:<\/p>\n<ul>\n<li>HTTP (e.g., web access)<\/li>\n<li>SMTP (sending e-mails)<\/li>\n<li>FTP (uploading and downloading files)<\/li>\n<\/ul>\n<p>To use luasocket you need to load the libraries and away you go. Here&#8217;s a trivial example which makes an HTTP call to a server, stores the server&#8217;s response in a Lua table and typesets it. To build more advanced examples you&#8217;ll need to read about the <a href=\"http:\/\/w3.impa.br\/~diego\/software\/luasocket\/ltn12.html\">ltn12 module<\/a>.<\/p>\n<p><code><br \/>\n\\directlua{<\/code><\/p>\n<p><code>local ltn12 = require(\"ltn12\")<br \/>\nlocal http = require(\"socket.http\")<\/p>\n<p>function grabtext(httplink)<br \/>\nlocal tab = {}<br \/>\nlocal res = http.request{url = httplink, sink = ltn12.sink.table(tab)}<br \/>\nreturn tab<br \/>\nend<\/p>\n<p><\/code><\/p>\n<p><code>local t = grabtext(\"http:\/\/your_url_here\")<br \/>\ntex.print(t[1])<br \/>\n}<br \/>\n<\/code><\/p>\n<p>Vastly more complex examples could be built, of course.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>One feature of LuaTeX which might prove useful in some circumstances is its ability to connect to networks through TCP\/IP. This facility is due to the luasocket TCP\/IP networking library which is built into the executable. In addition to the low-level TCP\/IP facilities, luasocket provides a number of support modules which make the following tasks [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[15],"tags":[],"class_list":["post-1119","post","type-post","status-publish","format-standard","hentry","category-examples"],"blocksy_meta":[],"_links":{"self":[{"href":"https:\/\/www.readytext.co.uk\/index.php?rest_route=\/wp\/v2\/posts\/1119","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.readytext.co.uk\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.readytext.co.uk\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.readytext.co.uk\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.readytext.co.uk\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=1119"}],"version-history":[{"count":4,"href":"https:\/\/www.readytext.co.uk\/index.php?rest_route=\/wp\/v2\/posts\/1119\/revisions"}],"predecessor-version":[{"id":3262,"href":"https:\/\/www.readytext.co.uk\/index.php?rest_route=\/wp\/v2\/posts\/1119\/revisions\/3262"}],"wp:attachment":[{"href":"https:\/\/www.readytext.co.uk\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=1119"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.readytext.co.uk\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=1119"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.readytext.co.uk\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=1119"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}