Re: luasocket and selecting from files.
[
Date Prev][
Date Next][
Thread Prev][
Thread Next]
[
Date Index]
[
Thread Index]
- Subject: Re: luasocket and selecting from files.
- From: Jorge <xxopxe@...>
- Date: 2015年7月01日 10:22:40 +0200
On 01/07/15 04:29, Sean Conner wrote:
From files, like '/usr/local/include/lua.h' or from any type of device
that uses a file handle? I only ask this because using select() on an
actual file (like '/usr/local/include/lua.h') will *always* be
readable and writable---i.e. there's just no use in using select() for
files [1] as Linux does some aggressive memory caching. select() [2]
works much better for sockets and character devices like /dev/tty.
Yes, is for device files that block reads when there is no data. And for
plain files too.
To get the underlying file descriptor from a FILE *, you need to use
the C function fileno().
I see... Then luasocket can not be used on it's own for this purpose, I
need another chunk o C code somewhere. I my environment luasocket is the
only external library available, so some rethinking is needed.
Is there any working code out there doing this?
For files? I don't know, but it would be similar with files (as sockets
are file handles).
I was thinking code preparing a file handle for serving with luasocket.
There seems to be some weird dancing involved with creating a connected
socket, replacing its fd, then invalidating something setting a fd of
-1, etc.
Thanks,
Jorge