diff options
author | Rob Kendrick (humdrum) <rjek@rjek.com> | 2013-06-11 12:45:02 +0100 |
---|---|---|
committer | Rob Kendrick (humdrum) <rjek@rjek.com> | 2013-06-11 12:45:02 +0100 |
commit | 1a4756191a410b5fe9128356d274728a2ebe5a79 (patch) | |
tree | dff7dcd7e6267d9c39f6ea834a6b5705481350db | |
parent | 20dcdb3c45c27445806260d4b6e94f105c62338e (diff) | |
download | luxio-1a4756191a410b5fe9128356d274728a2ebe5a79.tar.gz |
Add simple socket usage example
-rwxr-xr-x | examples/simple-socket.lua | 24 |
1 files changed, 24 insertions, 0 deletions
diff --git a/examples/simple-socket.lua b/examples/simple-socket.lua new file mode 100755 index 0000000..0885c55 --- /dev/null +++ b/examples/simple-socket.lua @@ -0,0 +1,24 @@ +#!../luxio-5.1 + +package.path = package.path .. ":../?.lua" +package.cpath = package.cpath .. ":../?.so" + +sio = require "luxio.simple" + +mysock = assert(sio.connect("www.rjek.com", "http")) +print("mysock: " .. tostring(mysock)) + +print "Sending request..." +assert(mysock:writev("GET / HTTP/1.1\r\n", + "Host: www.rjek.com\r\n", + "Connection: close\r\n", + "\r\n")) + +print "Reading reply..." + +print(assert(mysock:read "*a")) + +print "Closing socket..." + +assert(mysock:close()) + |