Skip to content

franklange/bln_net

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

18 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

bln_net

A small socket library.

Dependencies

  • bln_queue
  • Boost::asio

Server

#include <bln_net/udp.hpp>
#include <iostream>

auto main() -> int
{
    bln_net::udp::socket_asio socket{8000};

    while (true)
    {
        auto packet = socket.wait();
        std::cout << "[rx] " << packet.to_string() << std::endl;
        // [rx] [127.0.0.1:9000|b'2]

        socket.put(std::move(packet));
    }

    return 0;
}

Client

#include <bln_net/udp.hpp>
#include <bln_net/utils.hpp>

auto main() -> int
{
    bln_net::udp::socket_asio socket{9000};

    socket.put({{"127.0.0.1", 8000}, bln_net::to_bytes("hi")});

    const auto packet = socket.wait();
    std::cout << "[rx] " << packet.to_string() << std::endl;
    // [rx] [127.0.0.1:8000|b'2]

    return 0;
}

About

A small socket library.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published