diegonehab/luasocket — pull request #48 by moteus (2013-05-30 09:27:58+00:00)
Title: Add. acceptfd method.

On windows we can pass this `fd` only between threads.

`socket.tcp` can accept fd and socket type ('master'(default), 'client') and create new `socket` object.

acceptfd method can be used to write multi-threaded server.
```lua
-- main thread
local fd = srv_sock:acceptfd()
Threads.runfile('echo.lua', fd)

-- echo.lua
local fd = ...
local sock = socket.tcp(fd,'client')
```

or to interact with library such as [ESL](http://wiki.freeswitch.org/wiki/Event_Socket_Library)
```lua
local fd = srv_sock:acceptfd()
Threads.runfile('worker.lua', fd)

-- worker.lua
local sock = ESLconnection((...))
```

If we need just close fd (for example we can not run worker thread) we should call `socket.tcp(fd,'client'):close()`