Skip to content

flouthoc/envelop.c

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

17 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

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

About

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

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Contributors 4

  •  
  •  
  •  
  •