Author Topic: Lua Socket Work  (Read 1835 times)

0 Members and 1 Guest are viewing this topic.

Offline Imperceptus

  • Newbie
  • *
  • Posts: 3
  • Karma: +0/-0
Lua Socket Work
« on: 04 September, 2005, 21:23:44 »
I have read the docs, and I am trying to make a standalone lua exe to connect to a server using socket.tcp and parse the the datarecieved.  Im more the familiar in how to do this in simple languages like Visual Basic.  Some help if anyone can suggest anything.

Code: [Select]
connection = require "luasocket"
socket = require "socket"

local status = connection:recieve(2^10)
repeat
connection = assert(socket.connect(host, port))
connection:timeout(20)
    connection:send(username .. "\r" .. password .. "\r\n")
until status == "connected"


I think that should connect to the server, but if it does im a bit unaware as how to capture incoming data to parse it.  In c I would hook on inheritance

« Last Edit: 04 September, 2005, 21:29:49 by Imperceptus »

PtokaX forum

Lua Socket Work
« on: 04 September, 2005, 21:23:44 »

Offline Imperceptus

  • Newbie
  • *
  • Posts: 3
  • Karma: +0/-0
(No subject)
« Reply #1 on: 05 September, 2005, 20:46:36 »
should i try that in a loop until i recieve a complete packet? or  once i use it will it wait in execution until it recieves something.

Offline Imperceptus

  • Newbie
  • *
  • Posts: 3
  • Karma: +0/-0
(No subject)
« Reply #2 on: 05 September, 2005, 20:59:12 »
should i try that in a loop until i recieve a complete packet? or  once i use it will it wait in execution until it recieves something.

I would like to wait for the socket to recieve data, grab the first two bytes of it to refer to how long the rest of the data im trying to parse will be.


crap sorry for double post
« Last Edit: 05 September, 2005, 21:14:04 by Imperceptus »

PtokaX forum

(No subject)
« Reply #2 on: 05 September, 2005, 20:59:12 »