Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 2 additions & 10 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
cmake_minimum_required(VERSION 3.28)
project(
CppNet
VERSION 0.8.0
VERSION 0.9.0
LANGUAGES CXX)

# net requires at least C++20
Expand All @@ -13,14 +13,6 @@ include(FetchContent)
# https://github.com/cpm-cmake/CPM.cmake#adding-cpm
include(cmake/CPM.cmake)

# Add stdexec as a dependency
CPMAddPackage(
URI "gh:NVIDIA/stdexec#main"
OPTIONS
"STDEXEC_BUILD_EXAMPLES OFF"
"STDEXEC_BUILD_TESTING OFF"
)

# Add AsyncBerkeley as a dependency.
CPMAddPackage(
URI "gh:kcexn/async-berkeley@0.4.1"
Expand All @@ -34,7 +26,7 @@ add_library(cppnet INTERFACE)
target_include_directories(
cppnet INTERFACE $<BUILD_INTERFACE:${PROJECT_SOURCE_DIR}/include/>
$<INSTALL_INTERFACE:${CMAKE_INSTALL_INCLUDEDIR}>)
target_link_libraries(cppnet INTERFACE asyncberk STDEXEC::stdexec)
target_link_libraries(cppnet INTERFACE asyncberk)
install(DIRECTORY ${PROJECT_SOURCE_DIR}/include/
DESTINATION ${CMAKE_INSTALL_INCLUDEDIR})

Expand Down
875 changes: 201 additions & 674 deletions LICENSE

Large diffs are not rendered by default.

28 changes: 13 additions & 15 deletions include/net/cppnet.hpp
Original file line number Diff line number Diff line change
@@ -1,18 +1,16 @@
/* Copyright (C) 2025 Kevin Exton (kevin.exton@pm.me)
*
* cppnet is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published
* by the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* cppnet is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with cppnet. If not, see <https://www.gnu.org/licenses/>.
*/
// Copyright 2025 Kevin Exton
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
/**
* @file cppnet.hpp
* @brief This file exports the public cppnet interface.
Expand Down
40 changes: 22 additions & 18 deletions include/net/detail/concepts.hpp
Original file line number Diff line number Diff line change
@@ -1,18 +1,16 @@
/* Copyright (C) 2025 Kevin Exton (kevin.exton@pm.me)
*
* cppnet is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published
* by the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* cppnet is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with cppnet. If not, see <https://www.gnu.org/licenses/>.
*/
// Copyright 2025 Kevin Exton
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
/**
* @file concepts.hpp
* @brief This file defines concepts for cppnet.
Expand All @@ -21,6 +19,7 @@
#ifndef CPPNET_CONCEPT_HPP
#define CPPNET_CONCEPT_HPP
#include <concepts>
#include <system_error>
// Forward declarations
namespace net::service {
struct async_context;
Expand All @@ -38,12 +37,17 @@ concept BasicLockable = requires(Lock lock) {
{ lock.unlock() } -> std::same_as<void>;
};

/** @brief ServiceLike describes types that behave like an application or
* service. */
/**
* @brief Constrains types that behave like an application or service.
* @details ServiceLike functions can mutate state in the asynchronous
* context.
* @note A ServiceLike may call `ctx.scope.request_stop()` any time it
* runs.
*/
template <typename S>
concept ServiceLike = requires(S service, service::async_context &ctx) {
{ service.signal_handler(1) } noexcept -> std::same_as<void>;
{ service.start(ctx) } noexcept -> std::same_as<void>;
{ service.start(ctx) } noexcept -> std::same_as<std::error_code>;
};

/** @brief This namespace is for timers and interrupts. */
Expand Down
28 changes: 13 additions & 15 deletions include/net/detail/immovable.hpp
Original file line number Diff line number Diff line change
@@ -1,18 +1,16 @@
/* Copyright (C) 2025 Kevin Exton (kevin.exton@pm.me)
*
* cppnet is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published
* by the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* cppnet is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with cppnet. If not, see <https://www.gnu.org/licenses/>.
*/
// Copyright 2025 Kevin Exton
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
/**
* @file immovable.hpp
* @brief This file defines immovable.
Expand Down
28 changes: 13 additions & 15 deletions include/net/detail/with_lock.hpp
Original file line number Diff line number Diff line change
@@ -1,18 +1,16 @@
/* Copyright (C) 2025 Kevin Exton (kevin.exton@pm.me)
*
* cppnet is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published
* by the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* cppnet is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with cppnet. If not, see <https://www.gnu.org/licenses/>.
*/
// Copyright 2025 Kevin Exton
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
/**
* @file with_lock.hpp
* @brief This file defines with_lock.
Expand Down
28 changes: 13 additions & 15 deletions include/net/service/async_context.hpp
Original file line number Diff line number Diff line change
@@ -1,18 +1,16 @@
/* Copyright (C) 2025 Kevin Exton (kevin.exton@pm.me)
*
* cppnet is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published
* by the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* cppnet is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with cppnet. If not, see <https://www.gnu.org/licenses/>.
*/
// Copyright 2025 Kevin Exton
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.

/**
* @file async_context.hpp
Expand Down
31 changes: 15 additions & 16 deletions include/net/service/async_tcp_service.hpp
Original file line number Diff line number Diff line change
@@ -1,18 +1,16 @@
/* Copyright (C) 2025 Kevin Exton (kevin.exton@pm.me)
*
* cppnet is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published
* by the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* cppnet is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with cppnet. If not, see <https://www.gnu.org/licenses/>.
*/
// Copyright 2025 Kevin Exton
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
/**
* @file async_tcp_service.hpp
* @brief This file declares an asynchronous tcp service.
Expand Down Expand Up @@ -112,8 +110,9 @@ class async_tcp_service {
/**
* @brief Start the service on the context.
* @param ctx The async context to start the service on.
* @return An error code indicating success.
*/
auto start(async_context &ctx) noexcept -> void;
auto start(async_context &ctx) noexcept -> std::error_code;
/**
* @brief Submits an asynchronous socket recv.
* @param ctx The async context to start the reader on.
Expand Down
31 changes: 15 additions & 16 deletions include/net/service/async_udp_service.hpp
Original file line number Diff line number Diff line change
@@ -1,18 +1,16 @@
/* Copyright (C) 2025 Kevin Exton (kevin.exton@pm.me)
*
* cppnet is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published
* by the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* cppnet is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with cppnet. If not, see <https://www.gnu.org/licenses/>.
*/
// Copyright 2025 Kevin Exton
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
/**
* @file async_udp_service.hpp
* @brief This file declares an asynchronous udp service.
Expand Down Expand Up @@ -115,8 +113,9 @@ class async_udp_service {
/**
* @brief Start the service on the context.
* @param ctx The async context to start the service on.
* @returns an error code indicating success.
*/
auto start(async_context &ctx) noexcept -> void;
auto start(async_context &ctx) noexcept -> std::error_code;
/**
* @brief Submits an asynchronous socket recv.
* @param ctx The async context to start the reader on.
Expand Down
Loading