Skip to content

richardhundt/ray

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

9 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

NAME

ray - simple, coroutine friendly libuv bindings for Lua

DESCRIPTION

Ray provides:

  • TCP and UDP sockets
  • filesystem operations
  • timers

Oh, and it schedules coroutines instead of using callbacks.

Example

TCP echo client:

local ray = require('ray')
ray.fiber(function()
   local server = ray.tcp()
   server:bind('127.0.0.1', 8080)
   server:listen(128)
   while true do
      local client = server:accept()
      local fib = ray.fiber(function()
         while true do
            local data = client:read()
            if data then
               client:write("you said: "..data)
            else
               client:close()
               break
            end
         end
      end)
   end
end)

ray.run()

About

Lua C API libuv bindings

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published