C++ peer to peer library, built on the top of boost

Overview

Breep

What is Breep?

Breep is a c++ bridged peer to peer library. What does that mean? It means that even though the network is constructed as a peer to peer one, there may be no direct connections between two dudes, say A and B, if these connections are impossible (due to poorly configured ports, for example). In that case, Breep will attempt to use another peer C as a bridge between A and B.
Breep is also a high-level library. You don't have to care on when peers connect, disconnect, send data, and on how to send your classes. You simply register listeners that get notified when peers come and go, when they send you stuff. You may even use serialization and send your own object directly through the network. Same goes for your listeners: you don't say 'I want to listen for piles of bytes', but instead you say 'I want to listen for fancy::MyClass'.

How do I use Breep::network ?

The best way to now it is to read the tutorials. Alternatively, you may read some examples and the online doc. But as a little preview, here is a 'Hello World!'-type example:

Here is how to create a network, start listening on port 1234, and send "Hello!" to any budy that connects:

BREEP_DECLARE_TYPE(std::string)

void co_listener(breep::tcp::network& network, const breep::tcp::peer& source) {
	network.send_object_to(source, std::string("Hello!"));
}

int main() {
	breep::tcp::network network(1234);
	network.add_connection_listener(&co_listener);
	network.sync_awake();
	return 0;
}

The BREEP_DECLARE_TYPE involved here is used to tell to breep::network that we will listen/send some std::strings. If you forget to do it, you will get a compile-time error.

There is how to do the opposite: the network starts listening on port 1233, tries to connect at localhost:1234, prints the first message it sees, then disconnect:

BREEP_DECLARE_TYPE(std::string)

void data_listener(breep::tcp::netdata_wrapper<std::string>& dw) {
    std::cout << dw.data << std::endl;
    dw.network.disconnect();
}

int main() {
    breep::tcp::network network(1233);
    network.add_data_listener<std::string>(&data_listener);
    if (!network.connect(boost::asio::ip::address_v4::loopback(), 1234)) {
        std::cout << "Failed to connect.\n";
        return 1;
    }
    network.join();
    return 0;
}

Please don't get confused: there is no UDP in this lib (yet).

Why should I use Breep::network ?

  • It's awesome!
  • It's high level: you can directly send and receive objects.
  • The overhead for this is low: if you set up well your serialization, you only have a fixed 64bits extra overhead (compared to sending raw bytes to the p2p network — in comparison, TCP has 320bits of overhead only for its header)
  • It's easy to get in: just read the examples, you'll see!

Why should I NOT use Breep::network ?

  • It has not been tested as much as it should have been.
  • It's probably broken for BigEndian architecture (I have no way to test this, sorry ; a warning should be displayed on such architectures.)
  • It's very, very slow to compile with.

Requirements

Resource Requirement
Compiler C++14 compliant or above
Boost Boost 1.55 or above

Road Map

Milestone Feature Status
0.1 Peer to peer network management complete
0.1 Instantiated objects delivery complete
1.0 Improved serialization complete
1.0 Multiple objects delivery in one go complete
x.x Client server network management on hold

The project is currently on testing stage before the release of Breep 1.0.0

License

This work is under the European Union Public License v1.1.

You may get a copy of this license in your language from the European Commission here.

Extract of article 13 :

All linguistic versions of this Licence, approved by the European Commission, have identical value.
Parties can take advantage of the linguistic version of their choice.

Author

Lucas Lazare, an IT student frustrated from not being able to properly use java's broken network library, and inspired by KryoNet

Comments
  • Errors when building with Visual Studio IDE

    Errors when building with Visual Studio IDE

    I get the following errors during compilation ( Microsoft Visual Studio Ultimate 2013): error C2144: syntax error : 'bool' should be preceded by ';' error C4430: missing type specifier - int assumed. Note: C++ does not support default-int etc. all in type_traits.hpp. Unfortunately I do not have any experience using GCC. It will be much appreciated if you could help.

    wontfix 
    opened by AnubisYinepu 5
  • Logger in wrong namespace

    Logger in wrong namespace

    For example, in /include/breep/network/detail/object_builder.hpp, the logger is referenced as breep::logger.

    I believe it should be breep::detail::logger.

    This error was found while compiling the example code chat.

    Edit: This was using g++<4.9. This doesn't occur with g++5

    Edit2: Now getting a lot of BREEP_DECLARE_TEMPLATE-based errors. Saying things like: template argument 1 is invalid, parse error in template argument list, expected unqualified-id before '...' token. It says in type_traits.hpp to use BREEP_DECLARE_TYPE instead of BREEP_DECLARE_TEMPLATE if getting errors. Is this the recommended action to take (editing basic_peer.hpp, io_manager_base.hpp, etc?

    In file included from ../../include/breep/network/tcp.hpp:21:0,
                     from main.cpp:23:
    ../../include/breep/util/type_traits.hpp:66:221: error: expected ‘;’ at end of member declaration
              const std::string universal_name = std::string(#TType"<") + networking_traits_impl<typename std::tuple_element<0, std::tuple<T...>>::type>().universal_name + detail::identifier_from_tuple<detail::remove_type<0, T...>>().value + ">"; \
                                                                                                                                                                                                                                 ^
    ../../include/breep/network/basic_peer.hpp:166:1: note: in expansion of macro ‘BREEP_DECLARE_TEMPLATE’
     BREEP_DECLARE_TEMPLATE(breep::basic_peer)
     ^
    ../../include/breep/util/type_traits.hpp:66:221: error: declaration of ‘const string breep::detail::networking_traits_impl<breep::basic_peer<T ...> >::T’
              const std::string universal_name = std::string(#TType"<") + networking_traits_impl<typename std::tuple_element<0, std::tuple<T...>>::type>().universal_name + detail::identifier_from_tuple<detail::remove_type<0, T...>>().value + ">"; \
                                                                                                                                                                                                                                 ^
    ../../include/breep/network/basic_peer.hpp:166:1: note: in expansion of macro ‘BREEP_DECLARE_TEMPLATE’
     BREEP_DECLARE_TEMPLATE(breep::basic_peer)
     ^
    ../../include/breep/util/type_traits.hpp:63:16: error:  shadows template parm ‘class ... T’
          template <typename... T> \
                    ^
    ../../include/breep/network/basic_peer.hpp:166:1: note: in expansion of macro ‘BREEP_DECLARE_TEMPLATE’
     BREEP_DECLARE_TEMPLATE(breep::basic_peer)
     ^
    ../../include/breep/util/type_traits.hpp:66:222: error: expected unqualified-id before ‘...’ token
              const std::string universal_name = std::string(#TType"<") + networking_traits_impl<typename std::tuple_element<0, std::tuple<T...>>::type>().universal_name + detail::identifier_from_tuple<detail::remove_type<0, T...>>().value + ">"; \
                                                                                                                                                                                                                                  ...
    
    opened by han-so1omon 4
  • Possibility for network discovery/broadcast messages?

    Possibility for network discovery/broadcast messages?

    I'm interested in using this library for a project involving ad-hoc network building. How would you suggest building network discovery features to Breep? The simplest way that I can think of is to add broadcast messaging (using UDP, I suppose) to build a routing table. At least one problem with that, though, is that UDP still needs a router I think. Is there some forum where we could discuss this?

    Alternatively, do you have links to sources where I can learn true peer-to-peer communication paradigm? Perhaps you have a diagram of Breep's comm flow or know of a similar one.

    Cheers

    not an issue 
    opened by han-so1omon 2
  • Compilation of the examples on Ubuntu 16.04 fails

    Compilation of the examples on Ubuntu 16.04 fails

    Checked out both current master branch and 0.1.0 tag. When trying to compile the examples by calling make, I get the following output: Building chat.elf [ -- ] (1/1) Building main.o from main.cpp...In file included from ../../include/breep/network/tcp.hpp:21:0, from main.cpp:21: ../../include/breep/util/type_traits.hpp:66:221: error: expected ‘;’ at end of member declaration const std::string universal_name = std::string(#TType"<") + networking_traits_impl<typename std::tuple_element<0, std::tuple<T...>>::type>().universal_name + detail::identifier_from_tuple<detail::remove_type<0, T...>>().value + ">"; \ ^ ../../include/breep/network/detail/object_builder.hpp:151:1: note: in expansion of macro ‘BREEP_DECLARE_TEMPLATE’ BREEP_DECLARE_TEMPLATE(breep::detail::object_builder) ^ ../../include/breep/util/type_traits.hpp:66:221: error: declaration of ‘const string breep::detail::networking_traits_impl<breep::detail::object_builder<T ...> >::T’ const std::string universal_name = std::string(#TType"<") + networking_traits_impl<typename std::tuple_element<0, std::tuple<T...>>::type>().universal_name + detail::identifier_from_tuple<detail::remove_type<0, T...>>().value + ">"; \ ^ ../../include/breep/network/detail/object_builder.hpp:151:1: note: in expansion of macro ‘BREEP_DECLARE_TEMPLATE’ BREEP_DECLARE_TEMPLATE(breep::detail::object_builder) ^ ../../include/breep/util/type_traits.hpp:63:16: error: shadows template parm ‘class ... T’ template <typename... T> \ ^ ../../include/breep/network/detail/object_builder.hpp:151:1: note: in expansion of macro ‘BREEP_DECLARE_TEMPLATE’ BREEP_DECLARE_TEMPLATE(breep::detail::object_builder) ^ ../../include/breep/util/type_traits.hpp:66:222: error: expected unqualified-id before ‘...’ token const std::string universal_name = std::string(#TType"<") + networking_traits_impl<typename std::tuple_element<0, std::tuple<T...>>::type>().universal_name + detail::identifier_from_tuple<detail::remove_type<0, T...>>().value + ">"; \ ^ ../../include/breep/network/detail/object_builder.hpp:151:1: note: in expansion of macro ‘BREEP_DECLARE_TEMPLATE’ BREEP_DECLARE_TEMPLATE(breep::detail::object_builder) ^ ../../include/breep/util/type_traits.hpp:66:206: error: parse error in template argument list const std::string universal_name = std::string(#TType"<") + networking_traits_impl<typename std::tuple_element<0, std::tuple<T...>>::type>().universal_name + detail::identifier_from_tuple<detail::remove_type<0, T...>>().value + ">"; \ ^ ../../include/breep/network/detail/object_builder.hpp:151:1: note: in expansion of macro ‘BREEP_DECLARE_TEMPLATE’ BREEP_DECLARE_TEMPLATE(breep::detail::object_builder) ^ ../../include/breep/util/type_traits.hpp:66:206: error: template argument 1 is invalid const std::string universal_name = std::string(#TType"<") + networking_traits_impl<typename std::tuple_element<0, std::tuple<T...>>::type>().universal_name + detail::identifier_from_tuple<detail::remove_type<0, T...>>().value + ">"; \ ^ ../../include/breep/network/detail/object_builder.hpp:151:1: note: in expansion of macro ‘BREEP_DECLARE_TEMPLATE’ BREEP_DECLARE_TEMPLATE(breep::detail::object_builder) ^ ../../include/breep/util/type_traits.hpp:66:221: error: expected ‘;’ at end of member declaration const std::string universal_name = std::string(#TType"<") + networking_traits_impl<typename std::tuple_element<0, std::tuple<T...>>::type>().universal_name + detail::identifier_from_tuple<detail::remove_type<0, T...>>().value + ">"; \ ^ ../../include/breep/network/io_manager_base.hpp:158:1: note: in expansion of macro ‘BREEP_DECLARE_TEMPLATE’ BREEP_DECLARE_TEMPLATE(breep::io_manager_base) ^ ../../include/breep/util/type_traits.hpp:66:221: error: declaration of ‘const string breep::detail::networking_traits_impl<breep::io_manager_base<T ...> >::T’ const std::string universal_name = std::string(#TType"<") + networking_traits_impl<typename std::tuple_element<0, std::tuple<T...>>::type>().universal_name + detail::identifier_from_tuple<detail::remove_type<0, T...>>().value + ">"; \ ^ ../../include/breep/network/io_manager_base.hpp:158:1: note: in expansion of macro ‘BREEP_DECLARE_TEMPLATE’ BREEP_DECLARE_TEMPLATE(breep::io_manager_base) ^ ../../include/breep/util/type_traits.hpp:63:16: error: shadows template parm ‘class ... T’ template <typename... T> \ ^ ../../include/breep/network/io_manager_base.hpp:158:1: note: in expansion of macro ‘BREEP_DECLARE_TEMPLATE’ BREEP_DECLARE_TEMPLATE(breep::io_manager_base) ^ ../../include/breep/util/type_traits.hpp:66:222: error: expected unqualified-id before ‘...’ token const std::string universal_name = std::string(#TType"<") + networking_traits_impl<typename std::tuple_element<0, std::tuple<T...>>::type>().universal_name + detail::identifier_from_tuple<detail::remove_type<0, T...>>().value + ">"; \ ^ ../../include/breep/network/io_manager_base.hpp:158:1: note: in expansion of macro ‘BREEP_DECLARE_TEMPLATE’ BREEP_DECLARE_TEMPLATE(breep::io_manager_base) ^ ../../include/breep/util/type_traits.hpp:66:206: error: parse error in template argument list const std::string universal_name = std::string(#TType"<") + networking_traits_impl<typename std::tuple_element<0, std::tuple<T...>>::type>().universal_name + detail::identifier_from_tuple<detail::remove_type<0, T...>>().value + ">"; \ ^ ../../include/breep/network/io_manager_base.hpp:158:1: note: in expansion of macro ‘BREEP_DECLARE_TEMPLATE’ BREEP_DECLARE_TEMPLATE(breep::io_manager_base) ^ ../../include/breep/util/type_traits.hpp:66:206: error: template argument 1 is invalid const std::string universal_name = std::string(#TType"<") + networking_traits_impl<typename std::tuple_element<0, std::tuple<T...>>::type>().universal_name + detail::identifier_from_tuple<detail::remove_type<0, T...>>().value + ">"; \ ^ ../../include/breep/network/io_manager_base.hpp:158:1: note: in expansion of macro ‘BREEP_DECLARE_TEMPLATE’ BREEP_DECLARE_TEMPLATE(breep::io_manager_base) ^ ../../include/breep/util/type_traits.hpp:66:221: error: expected ‘;’ at end of member declaration const std::string universal_name = std::string(#TType"<") + networking_traits_impl<typename std::tuple_element<0, std::tuple<T...>>::type>().universal_name + detail::identifier_from_tuple<detail::remove_type<0, T...>>().value + ">"; \ ^ ../../include/breep/network/basic_peer_manager.hpp:503:1: note: in expansion of macro ‘BREEP_DECLARE_TEMPLATE’ BREEP_DECLARE_TEMPLATE(breep::basic_peer_manager) ^ ../../include/breep/util/type_traits.hpp:66:221: error: declaration of ‘const string breep::detail::networking_traits_impl<breep::basic_peer_manager<T ...> >::T’ const std::string universal_name = std::string(#TType"<") + networking_traits_impl<typename std::tuple_element<0, std::tuple<T...>>::type>().universal_name + detail::identifier_from_tuple<detail::remove_type<0, T...>>().value + ">"; \ ^ ../../include/breep/network/basic_peer_manager.hpp:503:1: note: in expansion of macro ‘BREEP_DECLARE_TEMPLATE’ BREEP_DECLARE_TEMPLATE(breep::basic_peer_manager) ^ ../../include/breep/util/type_traits.hpp:63:16: error: shadows template parm ‘class ... T’ template <typename... T> \ ^ ../../include/breep/network/basic_peer_manager.hpp:503:1: note: in expansion of macro ‘BREEP_DECLARE_TEMPLATE’ BREEP_DECLARE_TEMPLATE(breep::basic_peer_manager) ^ ../../include/breep/util/type_traits.hpp:66:222: error: expected unqualified-id before ‘...’ token const std::string universal_name = std::string(#TType"<") + networking_traits_impl<typename std::tuple_element<0, std::tuple<T...>>::type>().universal_name + detail::identifier_from_tuple<detail::remove_type<0, T...>>().value + ">"; \ ^ ../../include/breep/network/basic_peer_manager.hpp:503:1: note: in expansion of macro ‘BREEP_DECLARE_TEMPLATE’ BREEP_DECLARE_TEMPLATE(breep::basic_peer_manager) ^ ../../include/breep/util/type_traits.hpp:66:206: error: parse error in template argument list const std::string universal_name = std::string(#TType"<") + networking_traits_impl<typename std::tuple_element<0, std::tuple<T...>>::type>().universal_name + detail::identifier_from_tuple<detail::remove_type<0, T...>>().value + ">"; \ ^ ../../include/breep/network/basic_peer_manager.hpp:503:1: note: in expansion of macro ‘BREEP_DECLARE_TEMPLATE’ BREEP_DECLARE_TEMPLATE(breep::basic_peer_manager) ^ ../../include/breep/util/type_traits.hpp:66:206: error: template argument 1 is invalid const std::string universal_name = std::string(#TType"<") + networking_traits_impl<typename std::tuple_element<0, std::tuple<T...>>::type>().universal_name + detail::identifier_from_tuple<detail::remove_type<0, T...>>().value + ">"; \ ^ ../../include/breep/network/basic_peer_manager.hpp:503:1: note: in expansion of macro ‘BREEP_DECLARE_TEMPLATE’ BREEP_DECLARE_TEMPLATE(breep::basic_peer_manager) ^ ../../include/breep/util/type_traits.hpp:66:221: error: expected ‘;’ at end of member declaration const std::string universal_name = std::string(#TType"<") + networking_traits_impl<typename std::tuple_element<0, std::tuple<T...>>::type>().universal_name + detail::identifier_from_tuple<detail::remove_type<0, T...>>().value + ">"; \ ^ ../../include/breep/network/basic_network.hpp:653:1: note: in expansion of macro ‘BREEP_DECLARE_TEMPLATE’ BREEP_DECLARE_TEMPLATE(breep::basic_network) ^ ../../include/breep/util/type_traits.hpp:66:221: error: declaration of ‘const string breep::detail::networking_traits_impl<breep::basic_network<T ...> >::T’ const std::string universal_name = std::string(#TType"<") + networking_traits_impl<typename std::tuple_element<0, std::tuple<T...>>::type>().universal_name + detail::identifier_from_tuple<detail::remove_type<0, T...>>().value + ">"; \ ^ ../../include/breep/network/basic_network.hpp:653:1: note: in expansion of macro ‘BREEP_DECLARE_TEMPLATE’ BREEP_DECLARE_TEMPLATE(breep::basic_network) ^ ../../include/breep/util/type_traits.hpp:63:16: error: shadows template parm ‘class ... T’ template <typename... T> \ ^ ../../include/breep/network/basic_network.hpp:653:1: note: in expansion of macro ‘BREEP_DECLARE_TEMPLATE’ BREEP_DECLARE_TEMPLATE(breep::basic_network) ^ ../../include/breep/util/type_traits.hpp:66:222: error: expected unqualified-id before ‘...’ token const std::string universal_name = std::string(#TType"<") + networking_traits_impl<typename std::tuple_element<0, std::tuple<T...>>::type>().universal_name + detail::identifier_from_tuple<detail::remove_type<0, T...>>().value + ">"; \ ^ ../../include/breep/network/basic_network.hpp:653:1: note: in expansion of macro ‘BREEP_DECLARE_TEMPLATE’ BREEP_DECLARE_TEMPLATE(breep::basic_network) ^ ../../include/breep/util/type_traits.hpp:66:206: error: parse error in template argument list const std::string universal_name = std::string(#TType"<") + networking_traits_impl<typename std::tuple_element<0, std::tuple<T...>>::type>().universal_name + detail::identifier_from_tuple<detail::remove_type<0, T...>>().value + ">"; \ ^ ../../include/breep/network/basic_network.hpp:653:1: note: in expansion of macro ‘BREEP_DECLARE_TEMPLATE’ BREEP_DECLARE_TEMPLATE(breep::basic_network) ^ ../../include/breep/util/type_traits.hpp:66:206: error: template argument 1 is invalid const std::string universal_name = std::string(#TType"<") + networking_traits_impl<typename std::tuple_element<0, std::tuple<T...>>::type>().universal_name + detail::identifier_from_tuple<detail::remove_type<0, T...>>().value + ">"; \ ^ ../../include/breep/network/basic_network.hpp:653:1: note: in expansion of macro ‘BREEP_DECLARE_TEMPLATE’ BREEP_DECLARE_TEMPLATE(breep::basic_network) ^ ../../include/breep/util/type_traits.hpp:66:221: error: expected ‘;’ at end of member declaration const std::string universal_name = std::string(#TType"<") + networking_traits_impl<typename std::tuple_element<0, std::tuple<T...>>::type>().universal_name + detail::identifier_from_tuple<detail::remove_type<0, T...>>().value + ">"; \ ^ main.cpp:88:1: note: in expansion of macro ‘BREEP_DECLARE_TEMPLATE’ BREEP_DECLARE_TEMPLATE(chat_message) ^ ../../include/breep/util/type_traits.hpp:66:221: error: declaration of ‘const string breep::detail::networking_traits_impl<chat_message<T ...> >::T’ const std::string universal_name = std::string(#TType"<") + networking_traits_impl<typename std::tuple_element<0, std::tuple<T...>>::type>().universal_name + detail::identifier_from_tuple<detail::remove_type<0, T...>>().value + ">"; \ ^ main.cpp:88:1: note: in expansion of macro ‘BREEP_DECLARE_TEMPLATE’ BREEP_DECLARE_TEMPLATE(chat_message) ^ ../../include/breep/util/type_traits.hpp:63:16: error: shadows template parm ‘class ... T’ template <typename... T> \ ^ main.cpp:88:1: note: in expansion of macro ‘BREEP_DECLARE_TEMPLATE’ BREEP_DECLARE_TEMPLATE(chat_message) ^ ../../include/breep/util/type_traits.hpp:66:222: error: expected unqualified-id before ‘...’ token const std::string universal_name = std::string(#TType"<") + networking_traits_impl<typename std::tuple_element<0, std::tuple<T...>>::type>().universal_name + detail::identifier_from_tuple<detail::remove_type<0, T...>>().value + ">"; \ ^ main.cpp:88:1: note: in expansion of macro ‘BREEP_DECLARE_TEMPLATE’ BREEP_DECLARE_TEMPLATE(chat_message) ^ ../../include/breep/util/type_traits.hpp:66:206: error: parse error in template argument list const std::string universal_name = std::string(#TType"<") + networking_traits_impl<typename std::tuple_element<0, std::tuple<T...>>::type>().universal_name + detail::identifier_from_tuple<detail::remove_type<0, T...>>().value + ">"; \ ^ main.cpp:88:1: note: in expansion of macro ‘BREEP_DECLARE_TEMPLATE’ BREEP_DECLARE_TEMPLATE(chat_message) ^ ../../include/breep/util/type_traits.hpp:66:206: error: template argument 1 is invalid const std::string universal_name = std::string(#TType"<") + networking_traits_impl<typename std::tuple_element<0, std::tuple<T...>>::type>().universal_name + detail::identifier_from_tuple<detail::remove_type<0, T...>>().value + ">"; \ ^ main.cpp:88:1: note: in expansion of macro ‘BREEP_DECLARE_TEMPLATE’ BREEP_DECLARE_TEMPLATE(chat_message) ^ Makefile:224: die Regel für Ziel „build/main.o“ scheiterte make[1]: *** [build/main.o] Fehler 1 Makefile:161: die Regel für Ziel „all“ scheiterte make: *** [all] Fehler 2

    The dependancies are installed. Do I need a special compiler version?

    opened by Flautz 1
  • Adding user data in basic_peer

    Adding user data in basic_peer

    It could be useful to have the possibility of adding data in basic_peer, accessible from user code, so that they can avoid using an extra map of their own when they would otherwise need it

    feature 
    opened by Organic-Code 1
  • Enable raw and smart pointer serialization

    Enable raw and smart pointer serialization

    Pointers serialization does not work out of the box. this is a missing feature, and deep serialization should be enabled for raw pointers and smart pointers (namely std::weak_ptr, std::shared_ptr and std::unique_ptr)

    enhancement 
    opened by Organic-Code 1
  • Change the serialization system

    Change the serialization system

    Because of the way boost's serialization is used, it is not possible to send a class without first copying it (at least for const refs), which is quite bad.

    One solution could be to implement a custom serialization system.

    enhancement 
    opened by Organic-Code 1
  • Add bytes hook on basic_network

    Add bytes hook on basic_network

    Adding hooks after serializing objects and before deserializing them could be useful in some circumstances (encryption & decryption, compression & decompression, …)

    enhancement feature 
    opened by Organic-Code 0
  • Conan package for Breep

    Conan package for Breep

    Hello, Do you know about Conan? Conan is modern dependency manager for C++. And will be great if your library will be available via package manager for other developers.

    Here you can find example, how you can create package for the library.

    If you have any questions, just ask :-)

    opened by zamazan4ik 3
  • Add an ID system?

    Add an ID system?

    Anyone can connect to any peer network (provided that they have the same protocol ID), even though they are from a completely different program

    Although this is unlikely, it should be taken into account, maybe by adding an ID when the network is created and checking it on incomming connections.

    feature 
    opened by Organic-Code 0
Releases(0.1.0)
  • 0.1.0(May 26, 2017)

    Breep

    What is Breep?

    Breep is a c++ bridged peer to peer library. What does that mean? It means that even though the network is constructed as a peer to peer one, there may be no direct connections between two dudes, say A and B, if these connections are impossible (due to poorly configured ports, for example). In that case, Breep will attempt to use another peer C as a bridge between A and B.
    Breep is also a high-level library. You don't have to care on when peers connect, disconnect, send data, and on how to send your classes. You simply register listeners that get notified when peers come and go, when they send you stuff. You may even use serialization and send your own object directly through the network. Same goes for your listeners: you don't say 'I want to listen for piles of bytes', but instead you say 'I want to listen for fancy::MyClass'.

    How do I use Breep::network ?

    The best way to now it is to read its examples or to read the online doc. But as a little preview, here is a small one

    Here is how to create a network, start listening on port 1234, and send "Hello!" to any budy that connects:

    BREEP_DECLARE_TYPE(std::string)
    
    void co_listener(breep::tcp::network& network, const breep::tcp::peer& source) {
    	network.send_object_to(source, std::string("Hello!"));
    }
    
    int main() {
    	breep::tcp::network network(1234);
    	network.add_connection_listener(&co_listener);
    	network.sync_awake();
    	return 0;
    }
    

    The BREEP_DECLARE_TYPE involved here is used to tell to breep::network that we will listen/send some std::strings. If you forget to do it, you will get a compile-time error.

    There is how to do the opposite: the network starts listening on port 1233, tries to connect at localhost:1234, prints the first message it sees, then disconnect:

    BREEP_DECLARE_TYPE(std::string)
    
    void data_listener(breep::tcp::netdata_wrapper<std::string>& dw) {
        std::cout << dw.data << std::endl;
        dw.network.disconnect();
    }
    
    int main() {
        breep::tcp::network network(1233);
        network.add_data_listener<std::string>(&data_listener);
        if (!network.connect(boost::asio::ip::address_v4::loopback(), 1234)) {
            std::cout << "Failed to connect.\n";
            return 1;
        }
        network.join();
        return 0;
    }
    

    Please don't get confused: there is no UDP in this lib (yet).

    Why should I use Breep::network ?

    • It's awesome!
    • It's high level: you can directly send and receive objects.
    • The overhead for this is low: if you set up well your serialization, you only have a fixed 64bits extra overhead
    • It's easy to get in: just read the examples, you'll see!

    Why should I NOT use Breep::network ?

    • It has not been tested as much as it should have been.
    • It's probably broken for BigEndian architecture (I have no way to test this, sorry ; a warning should be displayed on such architectures.)
    • It's very, very slow to compile with.

    Requirements

    | Resource | Requirement | |:------------------------------:|:-------------------------:| | Compiler | C++14 compliant or above | | Boost | Boost 1.55 or above |

    Road Map

    | Milestone | Feature | Status | |:--------------------------------------------------------:|:-----------------------------------:|:-----------:| | 0.1 | Peer to peer network management | complete | | 0.1 | Instantiated objects delivery | complete | | 1.0 | Improved serialization | development | | 1.0 | Multiple objects delivery in one go | pending | | x.x | Client server network management | on hold |

    License

    This work is under the European Union Public License v1.1.

    You may get a copy of this license in your language from the European Commission here.

    Extract of article 13 :

    All linguistic versions of this Licence, approved by the European Commission, have identical value.
    Parties can take advantage of the linguistic version of their choice.
    

    Author

    Lucas Lazare, an IT student frustrated from not being able to properly use java's broken network library, and inspired by KryoNet

    Source code(tar.gz)
    Source code(zip)
Owner
Lucas Lazare
C++ dev ; studied at UTBM (France) and UQAC (Canada, Québec)
Lucas Lazare
QuantumGate is a peer-to-peer (P2P) communications protocol, library and API written in C++.

About QuantumGate is a peer-to-peer (P2P) communications protocol, library and API. The long-term goal for QuantumGate is to become a platform for dis

Karel Donk 96 Dec 20, 2022
Packio - An asynchronous msgpack-RPC and JSON-RPC library built on top of Boost.Asio.

Header-only | JSON-RPC | msgpack-RPC | asio | coroutines This library requires C++17 and is designed as an extension to boost.asio. It will let you bu

Quentin Chateau 58 Dec 26, 2022
Zyre - an open-source framework for proximity-based peer-to-peer applications

Zyre - Local Area Clustering for Peer-to-Peer Applications Linux & MacOSX Windows Contents Overview Scope and Goals Ownership and License Using Zyre B

The ZeroMQ project 813 Jan 3, 2023
Husarnet is a Peer-to-Peer VPN to connect your laptops, servers and microcontrollers over the Internet with zero configuration.

Husarnet Client Husarnet is a Peer-to-Peer VPN to connect your laptops, servers and microcontrollers over the Internet with zero configuration. Key fe

Husarnet 180 Jan 1, 2023
Boost.GIL - Generic Image Library | Requires C++11 since Boost 1.68

Documentation GitHub Actions AppVeyor Azure Pipelines CircleCI Regression Codecov Boost.GIL Introduction Documentation Requirements Branches Community

Boost.org 154 Nov 24, 2022
HTTP and WebSocket built on Boost.Asio in C++11

HTTP and WebSocket built on Boost.Asio in C++11 Branch Linux/OSX Windows Coverage Documentation Matrix master develop Contents Introduction Appearance

Boost.org 3.6k Jan 4, 2023
An asynchronous web framework for C++ built on top of Qt

!!! I can no longer maintain this project. If you're interessed, please contact me and I can move the projetct to you !!! Tufão - an asynchronous web

Vinícius dos Santos Oliveira 556 Dec 28, 2022
requests-like networking library using boost for C++

cq == C++ Requests cq == C++ Requests is a "Python Requests"-like C++ header-only library for sending HTTP requests. The library is inspired a lot by

null 11 Dec 15, 2021
Ole Christian Eidheim 741 Dec 27, 2022
Lightweight, header-only, Boost-based socket pool library

Stream-client This is a lightweight, header-only, Boost-based library providing client-side network primitives to easily organize and implement data t

Tinkoff.ru 12 Aug 5, 2022
A very simple, fast, multithreaded, platform independent HTTP and HTTPS server and client library implemented using C++11 and Boost.Asio.

A very simple, fast, multithreaded, platform independent HTTP and HTTPS server and client library implemented using C++11 and Boost.Asio. Created to be an easy way to make REST resources available from C++ applications.

Ole Christian Eidheim 2.4k Dec 23, 2022
Minimalistic socket library inspired by Asio/Boost Asio, implemented in 1 single header file

cz-spas czspas (Small Portable Asynchronous Sockets) is minimalistic socket library inspired by Asio/Boost Asio, implemented in 1 single header file.

Rui Figueira 26 Nov 30, 2022
Asynchronous gRPC with Boost.Asio executors

asio-grpc This library provides an implementation of boost::asio::execution_context that dispatches work to a grpc::CompletionQueue. Making it possibl

Dennis 180 Dec 31, 2022
Boost headers

About This repository contains a set of header files from Boost. Can be useful when using header only libraries. How to use You can easily include the

null 2 Oct 16, 2021
Boost.org signals2 module

Signals2, part of collection of the Boost C++ Libraries, is an implementation of a managed signals and slots system. License Distributed under the Boo

Boost.org 52 Dec 1, 2022
Boost.org property_tree module

Maintainer This library is currently maintained by Richard Hodges with generous support from the C++ Alliance. Build Status Branch Status develop mast

Boost.org 36 Dec 6, 2022
Boost::ASIO low-level redis client (connector)

bredis Boost::ASIO low-level redis client (connector), github gitee Features header only zero-copy (currently only for received replies from Redis) lo

Ivan Baidakou 142 Dec 8, 2022
Super-project for modularized Boost

Boost C++ Libraries The Boost project provides free peer-reviewed portable C++ source libraries. We emphasize libraries that work well with the C++ St

Boost.org 5.4k Jan 8, 2023
Level up your Beat Saber experience on Quest! AnyTweaks provides various tweaks to help boost your experience on Quest, such as Bloom, FPS Counter and more.

Need help/support? Ask in one of BSMG's support channels for Quest, or join my Discord server! AnyTweaks Level up your Beat Saber experience on Quest!

kaitlyn~ 19 Nov 20, 2022