[ZeroBrane Studio] Re: luasocket receive

  • From: Renaud Kern <renaud.kern@xxxxxxxxx>
  • To: zerobrane@xxxxxxxxxxxxx
  • Date: Thu, 4 Sep 2014 10:05:23 +0200

Thank you for your response Paul.

You're right it's working now.

Best,

Renaud




2014-09-02 18:29 GMT+02:00 Paul K <paul@xxxxxxxxxxxxx>:

> Hi Renaud,
>
> > On ZBS the process execution freeze actually when "receive()" is called :
> local line, err, partial = client:receive("*l")
> > Is luasocket in conflict with ZBS ?
>
> No, shouldn't be. I don't see any issue with the slightly modified
> script (I fixed the usage of line/result/rslt):
>
> local socket = require "socket"
> local server = assert(socket.bind("*", 3333))
>
> function listen(server)
>   local client = server:accept()
>   client:settimeout(10)
>   local line, err, partial = client:receive("*l")
>   -- do something and store result
>   if line then
>     client:send(line.."\n")
>   else
>     error(err)
>   end
>   client:close()
> end
>
> listen(server)
>
> This correctly executes with both Run/F6 and Debug/F5 for me; I tested
> with a normal "telnet localhost 3333" as the client and it echoes the
> content back and doesn't freeze under the debugger.
>
> Can you try with this example and check if you still have the issue?
>
> Paul.
>
> On Tue, Sep 2, 2014 at 7:23 AM, Renaud Kern <renaud.kern@xxxxxxxxx> wrote:
> > Hello,
> >
> > I've a lua script that use luasocket to listen to a specific port
> (3333). It
> > work fine on the terminal but stop on ZBS. The script basically do this :
> >
> > local socket = require "socket"
> > local server = assert(socket.bind("*", 3333))
> >
> > function listen(server)
> >     local client = server:accept()
> >     client:settimeout(10)
> >     local line, err, partial = client:receive("*l")
> >     -- do something and store result
> >     if result then
> >       client:send(rslt.."\n")
> >       client:close()
> >     else
> >       client:close()
> >     end
> >   end
> >
> >   while true do
> >     if listen(server)
> >   end
> >
> > On ZBS the process execution freeze actually when "receive()" is called :
> > local line, err, partial = client:receive("*l")
> >
> > Is luasocket in conflict with ZBS ?
> >
> > Thanks,
> >
> > Renaud
>
>

Other related posts: