GithubHelp home page GithubHelp logo

lulzzz / envelop.c Goto Github PK

View Code? Open in Web Editor NEW

This project forked from flouthoc/envelop.c

0.0 1.0 0.0 244 KB

Thread-less, event-loop based tiny http-server from scratch using epoll. Learning Purpose.

License: MIT License

C 100.00%

envelop.c's Introduction

envelop.c

Thread-less, event-loop based toy http-server from scratch. This project focuses on practical implementation of EPOLL for learning purpose.

drawing

Build

gcc -o envelop envelop.c
Starts server on default port: 3000
./envelop

Hit

http://127.0.0.1:3000/hello

Add your own Routes

See the Routes function Here

What is event-loop ?

Its an infinite loop which looks for any available events and performs required action on them.

Psuedo Code for event loop.
for (1){

	event = getReadyEvents();
    if(event == "task1"){
    	perform task1;
    }else if(event == "task2"){
    	perform task2;
    }
}
Theory

is a programming construct that waits for and dispatches events or messages in a program. It works by making a request to some internal or external "event provider" (that generally blocks the request until an event has arrived), and then it calls the relevant event handler ("dispatches the event"). The event-loop may be used in conjunction with a reactor, if the event provider follows the file interface, which can be selected or 'polled' (the Unix system call, not actual polling). The event loop almost always operates asynchronously with the message originator.

Epoll

envelop.c's People

Contributors

flouthoc avatar

Watchers

 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.