• Poser - a framework for (simple) POsix SERvices in C

    From Felix Palmen@21:1/5 to All on Fri Jun 9 20:56:18 2023
    Announing my new project: poser.

    # WWW

    https://zirias.github.io/poser/

    # License

    BSD 2-clause

    # Description

    This is a simple no-dependencies framework for implementing your typical (networking) service in C. It's designed to only use POSIX APIs, so it
    should be portable without platform-specific code to any OS that
    conforms to POSIX.

    It optionally offers TLS, in which case OpenSSL or some API-compatible
    library like LibreSSL is needed.

    # Design

    Poser works fully event-driven and async. It uses async/non-blocking
    POSIX APIs where available, and simulates async behavior using a
    threadpool when needed.

    The main event loop is built around pselect(), which means there's a
    hard scalability limit. Although the alternative in POSIX, ppoll(),
    wouldn't have this hard limit, it IMHO wouldn't be a huge gain, as
    ppoll() needs to copy more data on each call and therefore might perform
    even worse. In practice, it just won't perform well for more than around
    100 concurrent connections, so if you need this, better use libraries
    like e.g. libuv instead.

    The API is fully object-oriented and designed for stability, so new
    features are unlikely to break API or even ABI. All public type names, functions and even enum members are prefixed with a (short) "namespace"
    to avoid clashes with consumer code or other libraries.

    # Why?

    This project kind of "happened". When I had the need to write my own
    services for some specific use cases, I didn't find any library doing
    exactly what I want, so I instead implemented everything myself ... and
    a lot of generic code was copy&pasted from one project to the next.

    "Backporting" improvements in a new project to an older one became a
    real hassle, so I finally decided to pull all the generic code out into
    a new library/framework project.

    # Features

    Currently, there's just one library, libposercore. It offers

    * Generic daemonizing code, correctly handling a pidfile
    * A simple event-handling mechanism based on direct calls
    * A simple logging mechanism with configurable writers
    * A main service loop around pselect(), also handling typical signals
    * A threadpool to schedule jobs on
    * Abstractions for TCP or local Unix domain socket connections, servers
    and clients
    * Optional TLS support
    * Several utility classes and functions

    # Dependencies

    Well, I said "no-dependencies" and that's true for runtime when built
    without TLS support. Still:

    * [build] gcc or clang supporting C11
    * [build] GNU make
    * [build] doxygen to build reference API docs
    * [build/run] OpenSSL or compatible, when built WITH_TLS=1 (default)

    # Roadmap

    Short term: Currently working on some abstractions to describe a
    structure for configuration. This should provide a single source of
    truth, be able to parse from different sources (like, commandline
    arguments and/or a config file), be able to auto-generate usage and
    help output as well as a sample config file. Kind of likely to be
    completed.

    Long term: Add more specialized libs. Currently thinking of a
    "libposerweb" implementing HTTP (server/client) and maybe offering some
    helper stuff for HTML/JSON/... Also, there might be a "libposerirc" some
    day implementing the IRC protocol. Likeliness of realization: we will
    see.

    # Final words

    Purpose of this post is both to actually announce this project, hoping
    someone might have some use for it, and of course, to collect feedback
    if you want, thanks!

    Cheers, Felix

    --
    Dipl.-Inform. Felix Palmen <felix@palmen-it.de> ,.//..........
    {web} http://palmen-it.de {jabber} [see email] ,//palmen-it.de
    {pgp public key} http://palmen-it.de/pub.txt // """""""""""
    {pgp fingerprint} 6936 13D5 5BBF 4837 B212 3ACC 54AD E006 9879 F231

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From Rainer Weikusat@21:1/5 to Felix Palmen on Mon Jun 12 19:16:28 2023
    felix@palmen-it.de (Felix Palmen) writes:

    [...]


    The main event loop is built around pselect(), which means there's a
    hard scalability limit. Although the alternative in POSIX, ppoll(),

    JFTR: ppoll is not a POSIX interface.

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From Kenny McCormack@21:1/5 to rweikusat@talktalk.net on Mon Jun 12 20:40:14 2023
    In article <874jncv94z.fsf@doppelsaurus.mobileactivedefense.com>,
    Rainer Weikusat <rweikusat@talktalk.net> wrote:
    felix@palmen-it.de (Felix Palmen) writes:

    [...]


    The main event loop is built around pselect(), which means there's a
    hard scalability limit. Although the alternative in POSIX, ppoll(),

    JFTR: ppoll is not a POSIX interface.

    Yes. The manpage says: ppoll() is Linux-specific.

    --
    After Using Gender Slur Against AOC, GOP Rep. Yoyo Won't Apologize 'For Loving God'.

    That's so sweet...

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From Philip Guenther@21:1/5 to Kenny McCormack on Mon Jun 12 23:38:12 2023
    On Monday, June 12, 2023 at 1:40:18 PM UTC-7, Kenny McCormack wrote:
    In article <874jncv...@doppelsaurus.mobileactivedefense.com>,
    Rainer Weikusat <rwei...@talktalk.net> wrote:
    fe...@palmen-it.de (Felix Palmen) writes:
    ...
    The main event loop is built around pselect(), which means there's a
    hard scalability limit. Although the alternative in POSIX, ppoll(),

    JFTR: ppoll is not a POSIX interface.
    Yes. The manpage says: ppoll() is Linux-specific.

    In spring 2021, ppoll() was accepted for inclusion in issue 8 of the SUS/POSIX standard, with prototype

    int ppoll(struct pollfd fds[], nfds_t nfds, const struct timespec *restrict timeout, const sigset_t *restrict sigmask);

    (pselect() was added in issue 6. No, I don't know when issue 8 will be published)

    Philip Guenther

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From Felix Palmen@21:1/5 to All on Tue Jun 13 21:07:12 2023
    * Rainer Weikusat <rweikusat@talktalk.net>:
    JFTR: ppoll is not a POSIX interface.

    Thanks. From time to time, I'm amazed what's *not* in POSIX ;)

    So, pselect() was the safe choice anyways for something that should work without platform-specific code paths on any POSIX system.

    --
    Dipl.-Inform. Felix Palmen <felix@palmen-it.de> ,.//..........
    {web} http://palmen-it.de {jabber} [see email] ,//palmen-it.de
    {pgp public key} http://palmen-it.de/pub.txt // """""""""""
    {pgp fingerprint} 6936 13D5 5BBF 4837 B212 3ACC 54AD E006 9879 F231

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From Felix Palmen@21:1/5 to All on Tue Jun 13 21:29:50 2023
    * Felix Palmen <felix@palmen-it.de>:
    Announing my new project: poser.

    A little addendum: If you happen to use FreeBSD, poser is already
    available there as a port in devel/poser.

    That's not because I want to push it upon FreeBSD users, but because I
    earlier added tlsc (port: security/tlsc) after getting some positive
    feedback. In a nutshell, tlsc is a *very* simplified alternative to
    stunnel, under a BSD license and compatible with LibreSSL. It's one of
    the projects I refactored so far to use poser instead of my copy&pasted
    code, so poser just became a new dependency...

    I've also noticed poser is available in AUR, as it seems for the same
    reason (to support the latest version of tlsc) – can't tell anything
    about the quality of that package, I don't use Arch myself.

    --
    Dipl.-Inform. Felix Palmen <felix@palmen-it.de> ,.//..........
    {web} http://palmen-it.de {jabber} [see email] ,//palmen-it.de
    {pgp public key} http://palmen-it.de/pub.txt // """""""""""
    {pgp fingerprint} 6936 13D5 5BBF 4837 B212 3ACC 54AD E006 9879 F231

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)