Lunet is a coroutine-based networking library that provides synchronous APIs with asynchronous execution. It combines the power of C, LuaJIT, and libuv to deliver high-performance I/O operations while maintaining clean, readable code.
Coroutine-based: Write synchronous-style code that runs asynchronously
High Performance: Built on LuaJIT and libuv for optimal performance
Comprehensive: Includes filesystem, networking, database, signal, and timer operations
Type Safety: Complete type definitions for IDE support
Cross-platform: Works on Linux, macOS, and Windows
C Core: High-performance native implementation
LuaJIT: Fast Lua execution with FFI support
libuv: Cross-platform asynchronous I/O
Coroutines: Lua coroutines for concurrent programming
spawn(func): Create and run a new coroutine
sleep(ms): Suspend coroutine for specified milliseconds
Socket Module (lunet.socket)
listen(protocol, host, port): Create TCP server
accept(listener): Accept incoming connections
connect(host, port): Connect to remote server
read(client): Read data from socket
write(client, data): Write data to socket
getpeername(client): Get peer address
close(handle): Close socket
set_read_buffer_size(size): Configure buffer size
Filesystem Module (lunet.fs)
open(path, mode): Open file
close(fd): Close file
read(fd, size): Read from file
write(fd, data): Write to file
stat(path): Get file statistics
scandir(path): List directory contents
MySQL Module (lunet.mysql)
open(params): Open database connection
close(conn): Close database connection
query(conn, query): Execute SELECT query
exec(conn, query): Execute INSERT/UPDATE/DELETE
Signal Module (lunet.signal)
wait(signal): Wait for system signal
CMake 3.10+
LuaJIT 2.1+
libuv 1.x
MySQL client library (for MySQL module)
git clone https://github.com/xialeistudio/lunet.git
cd lunet
mkdir build &&cd build
cmake ..
make
Build with Custom Library Paths
If you have libraries installed in non-standard locations, you can specify the paths explicitly: