Non-blocking accept()

classic Classic list List threaded Threaded
6 messages Options
rje
Reply | Threaded
Open this post in threaded view
|

Non-blocking accept()

rje
Hi,

I've done a quick search of the lua-l archive, but I can't find a quick
answer... A toy I'm currently playing with needs a non-blocking accept()
function.  LuaSocket doesn't seem to provide this.  (It waits until a
connection is made).  Is it possible to make it return nil or similar
if a connection isn't waiting?  If not, does anybody know of a socket
library for Lua that would allow this?

Cheers,
-- 
Rob Kendrick - http://www.digital-scurf.org/
DEC diagnostics would run on a dead whale.
		-- Mel Ferentz

Reply | Threaded
Open this post in threaded view
|

Re: Non-blocking accept()

Diego Nehab-3
> I've done a quick search of the lua-l archive, but I can't find a quick
> answer... A toy I'm currently playing with needs a non-blocking accept()
> function.  LuaSocket doesn't seem to provide this.  (It waits until a
> connection is made).  Is it possible to make it return nil or similar
> if a connection isn't waiting?  If not, does anybody know of a socket
> library for Lua that would allow this?

Hi,

LuaSocket 1.2,  soon to be  released (less  then a week)  allows a
timeout to be  specified for the accept method  of server sockets.
The  function returns  nil and  "timeout" in  case noone  shows up
before a timeout condition.

It also  provides UDP support,  faster (way way faster)  line mode
I/O and a few other goodies.

Does anyone have  any other suggestion (wish)? Maybe I  can add it
before I close the release, or maybe some other time?

Regards,
Diego.


Reply | Threaded
Open this post in threaded view
|

LuaSocket wish-list

Pedro Miller Rabinovitch-3
LuaSocket 1.2,  soon to be  released (less  then a week)  allows a
timeout to be  specified for the accept method  of server sockets.
(...)
Does anyone have  any other suggestion (wish)? Maybe I  can add it
before I close the release, or maybe some other time?

There are two things I'd really like to see in LuaSocket sometime soon, but I'm not quite sure of the complexity of the elements involved -- perhaps you could enlighten me.

The first one would be to execute POST actions. I'm sure that's been in your sights lately as well.

The second -- and by far the much more interesting one -- would be the ability to emulate cookies. Say one optionally passes http_get a pair of callback functions, one to set and one to get cookies. Then one would be able to emulate cookie behavior as necessary.

Regards,

	Pedro.
--
Pedro Miller Rabinovitch
Gerente Geral de Tecnologia
Cipher Technology
www.cipher.com.br

Reply | Threaded
Open this post in threaded view
|

Re: LuaSocket wish-list

Diego Nehab-3
Hi Pedro, 

> >Does anyone have  any other suggestion (wish)? Maybe I  can add it
> >before I close the release, or maybe some other time?
> The first one would be to execute POST actions. I'm sure that's been 
> in your sights lately as well.

Yes. I am planning to implement the POST method. It should present no
problem.

> The second -- and by far the much more interesting one -- would be 
> the ability to emulate cookies. Say one optionally passes http_get a 
> pair of callback functions, one to set and one to get cookies. Then 
> one would be able to emulate cookie behavior as necessary.

Cookies are just mime headers. Since the http_get function returns all
headers received with the document and also alows the caller to specify
mime headers to be sent in the request, you should have no problem
whatsoever emulating them, except finding the documentation about it.
You can take a look at the CGILua implementation, but that would be
cheating. :-)

Regards,
Diego.


Reply | Threaded
Open this post in threaded view
|

Re: LuaSocket wish-list

Pedro Miller Rabinovitch-3
Diego,

 > The first one would be to execute POST actions. I'm sure that's been
 > in your sights lately as well.
Yes. I am planning to implement the POST method. It should present no
problem.

Nice to hear that. Currently waiting at the edge of my seat.

Cookies are just mime headers. Since the http_get function returns all
headers received with the document and also alows the caller to specify
mime headers to be sent in the request, you should have no problem
whatsoever emulating them, except finding the documentation about it.
You can take a look at the CGILua implementation, but that would be
cheating. :-)

See, now that's exactly what I meant when I said I wasn't "quite sure of the complexity of the elements involved" and that "perhaps you could enlighten me". There you go. I'll take a look into that ASAHP.

Speaking of CGILua -- any news coming from that front? When can we expect to see CGILua for Lua 4.0 come out?

Thanks,

	Pedro.
--
Pedro Miller Rabinovitch
Gerente Geral de Tecnologia
Cipher Technology
www.cipher.com.br

Reply | Threaded
Open this post in threaded view
|

Re: LuaSocket wish-list

Steve Dekorte-4
In reply to this post by Pedro Miller Rabinovitch-3
Pedro Miller Rabinovitch wrote:
> Speaking of CGILua -- any news coming from that front? When can we  
> expect to see  CGILua for Lua 4.0 come out? 

Anyone considered writing a coroutine based Lua web server?

Steve