3
2
Fork
You've already forked packeteer
2
Packeteer provides a simplified, asynchronous, event-based socket API.
  • C++ 94.5%
  • Meson 3.6%
  • Python 1%
  • C 0.8%
2024年10月17日 17:15:55 +02:00
.well-known Add wellknown funding url 2024年10月17日 17:15:55 +02:00
benchmarks Make building extras dependent on option 2022年10月17日 09:02:55 +02:00
changelog.d Add changelog snippet 2023年05月05日 08:45:15 +02:00
data Change build scripts from autotools to cmake (first cut) 2017年02月20日 14:08:40 +01:00
docs Add logo 2022年07月05日 18:11:43 +02:00
examples Make building extras dependent on option 2022年10月17日 09:02:55 +02:00
ext Comment out all TUN/TAP code on BSD (not implemented) 2023年05月02日 18:02:42 +02:00
include Add SPDX identifier 2022年07月25日 12:35:02 +02:00
lib Remove missing header on BSD/OSX 2023年05月02日 17:52:09 +02:00
scripts Need script executable 2023年05月05日 09:19:46 +02:00
subprojects For #26 , update subprojects 2022年05月18日 12:04:17 +02:00
test Make building extras dependent on option 2022年10月17日 09:02:55 +02:00
util Make building extras dependent on option 2022年10月17日 09:02:55 +02:00
.appveyor.yml #26 : ignore util tests on windows as long as the scheduler isn't 100% 2022年05月18日 16:49:28 +02:00
.appveyor_account.yml For #26 , prepare an update to appveyor scripts 2022年05月18日 16:25:22 +02:00
.gitignore For #26 , update Pipfile{.lock} 2022年05月18日 12:12:01 +02:00
.oclint Add oclint target + configuration 2020年05月14日 15:56:34 +02:00
.semgrepignore Update copyright notice; there was an error 2022年06月09日 14:49:45 +02:00
.woodpecker.yml Update woodpecker config 2023年05月05日 08:42:44 +02:00
AUTHORS Add SPDX identifier 2022年07月25日 12:35:02 +02:00
build-config.h.in Simplify error formatting; this is now in liberate 2020年08月27日 09:34:55 +02:00
CODE_OF_CONDUCT.md Add CoC, DCO, and CONTRIBUTING document, which also provides the 2020年02月05日 13:52:56 +01:00
codemeta.json Add SPDX identifier 2022年07月25日 12:35:02 +02:00
conandata.yml Conan build info 2022年10月17日 09:03:08 +02:00
conanfile.py Don't forget to package additional dirs 2023年05月05日 08:58:54 +02:00
CONTRIBUTING.md Update copyright notice; there was an error 2022年06月09日 14:49:45 +02:00
DCO.txt Add CoC, DCO, and CONTRIBUTING document, which also provides the 2020年02月05日 13:52:56 +01:00
LICENSE Fix typo in LICENSE 2022年07月25日 12:35:09 +02:00
meson.build Make building extras dependent on option 2022年10月17日 09:02:55 +02:00
meson_options.txt Make building extras dependent on option 2022年10月17日 09:02:55 +02:00
Pipfile Conan2 boilerplate 2023年05月05日 08:44:53 +02:00
Pipfile.lock Update lock file as well 2023年05月05日 08:55:17 +02:00
README.md Add logo 2022年07月05日 18:11:43 +02:00
towncrier.toml Boilerplate for towncrier & changelog entry 2022年06月02日 13:21:13 +02:00

Overview

status-badge Build status

Packeteer provides a cross-platform socket API in C++.

The aim of the project is to get high performance, asynchronous inter-process I/O into any project without the need for a ton of external libraries, or for writing cross-platform boilerplate.

Packeteer achieves this aim by:

  • Picking the best available event notification for the target system.
  • and providing a socket-like API for supported IPC.

The project was started a long time ago, but was not public until recently. Some of the code has been extensively used in commercial products.

Quick Start

You can browse the examples folder for an echo server and client implementation, each in ~100 lines of code. The gist, however, is this:

  1. Create a connector, which provides the socket-like API:
    auto conn = packeteer::connector{api, "tcp://192.168.0.1:4321"};
    auto err = conn.connect();
    
  2. If a server was listening on the given address and port, you can now start with I/O:
    size_t transferred = 0;
    err = conn.write(buf, buflen, transferred);
    err = conn.read(buf, buflen, transferred);
    
    This, of course, can fail if there is no data to transfer.
  3. Asynchronous I/O is achieved by registering callbacks for I/O events with a scheduler object.
    using namespace packeteer;
    auto sched = scheduler{api};
    sched.register_connector(PEV_IO_READ, conn,
     [*](time_point const & now, events_t events, connector * the_conn) -> error_t
     {
     // Is notified when the given connector is readable.
     the_conn->read(buf, buflen, transferred);
     }
     );
    
  4. The rest of the echoserver and echoclient implementations are taken up by asynchronously accepting connections and error handling.

Additional Things

The basics of packeteer are covered by the quick start above. However, there are optional additions to the library.

  • ext contains extensions to packteer in the form of optional connectors that may not be available on all platforms.
  • util contains utility functionality; optional code that helps in developing applications without being strictly necessary.

Building

Requirements

  • meson for the build system. Meson is most easily installed via python's pip tool. Installing Python als means you can use the android.py script for Android builds.
  • ninja or platform-specific tools for build execution.
  • Packeteer is implemented in C++, and requires some compiler support for the C++17 standard.
  • Depending on which scheduler implementation you want to use, packeteer may require specific OS and kernel versions, e.g. Linux 2.6.9+ for the epoll scheduler, etc.

If you're running a recent-ish UNIX-derivative, it's probably best to just download packeteer and try to compile it.

Instructions

  1. pip install meson
  2. mkdir build && cd build
  3. meson ..
  4. ninja

Instructions (Android)

  1. pip install meson pipenv
  2. pipenv install
  3. pipenv run ./android.py
  4. mkdir build && cd build
  5. meson --cross-file ../android-<target>.txt ..
  6. ninja

Replace <target> with the specific Android target you wish to build for.

Scope

Design Goals

  1. Cross platform (highest priority)
  2. Low usage complexity
  3. Stable API/ABI
  4. Packet oriented I/O friendly
  5. Scalable
  6. Efficient
  7. Extensible (lowest priority)

The ordering of the goals is somewhat important. If you're just looking for fast event notification, there are better projects out there. If you're just looking for TCP streams, there are better projects, etc.

The overarching goal is to have very little effort in developing client and server implementations for new low-level protocols.

Supported Connectors

  • TCP/IP via the "tcp", "tcp4" and "tcp6" schemes.
  • UDP/IP via the "udp", "udp4" and "udp6" schemes.
  • AF_LOCAL/AF_UNIX via the "local" scheme. Note that unnamed local sockets are emulated on Windows, and abstract local names are not supported on all platforms.
  • Windows named pipes via the "pipe" scheme.
  • POSIX named pipes via the "fifo" scheme.
  • The "anon" scheme maps to POSIX anonymous pipes, or Windows named pipes with a generated name, and is usable for IPC within a process.

License

See the COPYING file.