lua-users home
lua-l archive

[Date Prev][Date Next][Thread Prev][Thread Next] [Date Index] [Thread Index]


I just tried luasocket (Windows version) but I only seem to get garbage data. I guess I should have made some stupid mistake.

Here's what I did:
- downloaded luasocket-2.0.1-lua5.1-win32.zip from LuaForge
- downloaded lua5_1_2_Win32_bin.zip from LuaBinaries (LuaForge)
- setup LUA_PATH, LUA_CPATH as directed
- tried the http example in the docs. It worked
  (even if it just crashed when I used a statically compiled Lua 5.1)

This is my code:

  socket = require("socket")
  client = socket.tcp()
  client:settimeout(5)
  -- connect to my router's telnet port
  res,err = client:connect('192.168.127.1', 23)
  print(res,err)
  -- all OK till here
  res,err = client:receive('*l')
  for i = 1, #res do
    print(string.byte(res, i))
  end
  --
  client:close()

The router should say "BusyBox on (none) login:"
(that's what I get with telnet).
This is the actual output:

  1       nil
  255
  253
  1
  255
  253
  33
  255
  251
  1
  255
  251
  3

There is no more data (a second receive() blocks until timeout).
What did I do wrong?

  Enrico