kernelsauce / turbo

Turbo is a framework built for LuaJIT 2 to simplify the task of building fast and scalable network applications. It uses a event-driven, non-blocking, no thread design to deliver excellent performance and minimal footprint to high-load applications while also providing excellent support for embedded uses.
http://turbo.readthedocs.io/
Apache License 2.0
528 stars 84 forks source link

Windows: int file-descriptor for add_handler possible? #154

Closed Thomas12 closed 9 years ago

Thomas12 commented 9 years ago

I try to use add_handler for Windows and I also have a (int) file-descriptor that I pass to add_handler. I get "_LuaSocketPoll:register 184 READ" but 1-2 seconds later I get "attepmt to index a number value". What can I do to make the pure Windows file-descriptor integer suitable for add_handler? (The file descriptor number is from an external C-function). Under Linux passing a pure file-descriptor number works - can it also under Windows?

Thank you!

kernelsauce commented 9 years ago

At the moment it only support a socket (LuaSocket) instead of a number.

I think you can set the actual fd for LuaSockets through some hack.

Something like

local socket = require "luasocket" local sock = socket.tcp():setfd(10) ioloop:add_handler(sock,...)

Thomas12 commented 9 years ago

Nice idea! Thank you for that suggestion.

_LuaSocketPoll:register looks good, but then I get a "ioloop.lua:444: select failed".

Although in the luasocket c-code it seems it just does an ordinary "select" on fd's.

Later I found on some forums a few complaining that on Windows, select is only working for network sockets and not files. As I couldn't find much about that I do not know if that is the last word on that topic.

kernelsauce commented 9 years ago

Yeah, that could probably be right. Select (or any poll api) on disk backed FDs does not work for Linux/Unix.

kernelsauce commented 9 years ago

I will have a look at it when I have time. Just getting everything working is enough for now :).

kernelsauce commented 9 years ago

This one seems answered right? Select does not support disk FD's? The same as on Unix and Linux... Closing if no more comments arrive within reasonable time.