Giter Club home page Giter Club logo

libio's Introduction

libio

libio is a cross platform high performance io library written in C. It provides ability to write event driven servers and applications with continuous code without callback hell.

Alpha version

Aim of the project

  • Simplify network programming in C
  • Same API for differnet platforms
  • Hide complexity and provide simple and intuitive API
  • Make high performance a default option

CLI

# build
> make

# build debug
> make build=Debug

# install
> make install

# uninstall
> make uninstall

Samples

> make
> bin/file-server samples/todomvc/
# open browser and navigate to http://localhost:8080

API Reference

// All 'int' calls return 0 on success and errno on failure

typedef struct io_loop_t io_loop_t;
typedef void (*io_loop_fn)(io_loop_t* loop, void* arg);

int io_loop_start(io_loop_t** loop);
int io_loop_stop(io_loop_t* loop);
int io_loop_ref(io_loop_t* loop);
int io_loop_unref(io_loop_t* loop);
int io_loop_post(io_loop_t* loop, io_loop_fn entry, void* arg);
int io_loop_exec(io_loop_t* loop, io_loop_fn entry, void* arg);
int io_loop_sleep(uint64_t milliseconds);
int io_loop_idle(io_loop_t* loop, uint64_t milliseconds);


typedef struct io_event_t io_event_t;

int io_event_create(io_event_t** event);
int io_event_delete(io_event_t* event);
int io_event_notify(io_event_t* event);
int io_event_wait(io_event_t* event);


typedef struct io_stream_t io_stream_t;

int io_stream_create(io_stream_t** stream); // Creates a memory stream
int io_stream_close(io_stream_t* stream);
int io_stream_info(io_stream_t* stream, io_stream_info_t** info);
size_t io_stream_read(io_stream_t* stream, char* buffer, size_t length, int exact);
size_t io_stream_unread(io_stream_t* stream, const char* buffer, size_t length);
size_t io_stream_write(io_stream_t* stream, const char* buffer, size_t length);
int io_stream_pipe(io_stream_t* from, io_stream_t* to, size_t chunk_size, size_t* transferred);


typedef struct io_tcp_listener_t io_tcp_listener_t;

int io_tcp_listen(io_tcp_listener_t** listener, const char* ip, int port, int backlog);
int io_tcp_shutdown(io_tcp_listener_t* listener);
int io_tcp_accept(io_stream_t** stream, io_tcp_listener_t* listener);
int io_tcp_connect(io_stream_t** stream, const char* ip, int port, uint64_t timeout);


int io_file_create(const char* path);
int io_file_delete(const char* path);
int io_file_open(io_stream_t** stream, const char* path, io_file_options_t options);

// main entry
int io_run(io_loop_fn entry, void* arg);

Platforms

Tested on

  • Win64 (32 bit build)
  • Ubuntu64 (64 bit build)

ToDos

  • Test on all platforms with different architectures

Contacts

Email:[email protected]

Licence

MIT

libio's People

Contributors

xnko avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.