pylover / meloop

Monadic event loop for C using epoll.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

meloop (Monadic Event Loop)

Features

  • Async/non-blocking IO
  • IO: read, write, wait(using epoll)
  • TCP client: connectA
  • TCP server: listenA, acceptA
  • SSL/TLS: tlsA, tlsreadA, tlswriteA
  • Timer using linux timerfd: timeropenA, timersleepA
  • Random using /dev/urandom: randopenA, randreadA, randencA

Build

Dependencies

sudo apt install build-essential pkgconf openssl
make clean
make all
make clean all

Examples

Take a look at examples directory.

cd examples

make echoshell
./echoshell


make echoserver
./echoserver


make echoclient
./echoclient


make tlsclient
./tlsclient


make random
./random


make state
./state

Running Tests

cd tests
make clean runall

Profiling

gprof

Run desired example, signal it with CTRL+C, then:

cd examples

make echoserver
./echoserver

gprof echoserver

valgrind

sudo apt install valgrind

cd examples
make clean all 
make valgrind

Or

valgrind --tool=memcheck --leak-check=full ./echoserver
valgrind --tool=massif ./echoserver 

Example output

==56319== Memcheck, a memory error detector
==56319== Copyright (C) 2002-2017, and GNU GPL'd, by Julian Seward et al.
==56319== Using Valgrind-3.18.1 and LibVEX; rerun with -h for copyright info
==56319== Command: ./echoserver
==56319==
127.0.0.1:42658 Connected.
127.0.0.1:42658 Disconnected.
^C
SIGINT detected: 2
Terminating TCP Server
==56319==
==56319== HEAP SUMMARY:
==56319==     in use at exit: 0 bytes in 0 blocks
==56319==   total heap usage: 14 allocs, 14 frees, 2,384 bytes allocated
==56319==
==56319== All heap blocks were freed -- no leaks are possible
==56319==
==56319== For lists of detected and suppressed errors, rerun with: -s
==56319== ERROR SUMMARY: 0 errors from 0 contexts (suppressed: 0 from 0)

Coding Convention

  • C Macros: UPPER_CASE
  • Monads/Arrows: fooA
  • All others: lowercase with meloop_ prefix.

About

Monadic event loop for C using epoll.

License:GNU General Public License v3.0


Languages

Language:C 98.1%Language:Makefile 1.9%