File: simple-socket.lua

package info (click to toggle)
luxio 13-1
  • links: PTS
  • area: main
  • in suites: buster
  • size: 420 kB
  • ctags: 449
  • sloc: ansic: 3,117; makefile: 72; sh: 24
file content (24 lines) | stat: -rwxr-xr-x 530 bytes parent folder | download | duplicates (3)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
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())