Skip to content

SericaLaw/io-uring-tcp-server

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

2 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

io-uring-tcp-server

This is an example TCP server framework based on io_uring, the most vogue Linux asynchronous I/O interface. To learn more about io_uring: https://kernel.dk/io_uring.pdf

Prerequisites

  • Linux kernel version >= 5.7 (If not work, please try higher version)
  • liburing

Quick Start

Build and install liburing from source:

git clone https://github.com/axboe/liburing

cd liburing

./configure
make
make install

Build the server:

mkdir build
cd build

cmake ..
make

Run and test the example echo server ...

$ ./echo_uring.out
connection from client 127.0.0.1:34994 established
received from client 127.0.0.1:34994 : hello, world!
connection from client 127.0.0.1:34994 closed

... with telnet:

$ telnet 127.0.0.1 8888
Trying 127.0.0.1...
Connected to 127.0.0.1.
Escape character is '^]'.
hello, world!
hello, world!
Connection closed by foreign host.

Feel free to modify the callback logic or write another server!

int main() {
    int port{8888};
    UringServer server{port};
    server.connection_callback = on_connection_established;
    server.message_callback = on_message;
    server.connection_closed_callback = on_connection_closed;
    server.start();
}

About

An example TCP server framework based on io_uring

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published