|
On 11/26/2010 03:07 PM, jonsmirl@gmail.com wrote:
io.write() does not return 'bytes written'. How am I supposed to detect a buffer full condition (partial write)?
Jon, I have not used LuaSockets in a long time, but I did write a facility that may help you. It exposes the standard Unix character device calls (well, most of them). The actual return values a passed back up to Lua. In particular, write() returns the result of the write() call. select() is a bit tricky, but it too returns the actual int result. It has worked for me, though I'm sure there will be some edge cases that I haven't covered. I have a C module and a thin Lua wrapper for generating ioctl() commands, etc.
See the code at http://www.dkrogers.com/lua/fileio.tar.gz. You'll have to tweak the makefile since I did not include everything in the tarball. The documentation in the C lua_fileio.c should be fairly straight-forward (we always think so, don't we?). Feel free to email me directly if you choose to use it and have any problems.
Doug