From 8f8d51f4595c0e718220fdd5570e2e76a5035cbb Mon Sep 17 00:00:00 2001 From: BodgeMaster <> Date: Sun, 24 Mar 2024 10:45:30 +0100 Subject: [PATCH] lib/net/*: Move stuff around MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit I did this months ago with the intention to finally start implementing networking.... Yeah, that definitely panned out. Also, Git is drunk with how it says files have been renamed, they’re just empty apart from the license notice. --- src/lib/net/{client.cpp => connection.cpp} | 0 src/lib/net/connection.hpp | 42 ++++++++++++++++++++++ src/lib/net/{client.hpp => tcp_client.c} | 0 src/lib/net/{server.cpp => tcp_client.h} | 0 src/lib/net/{server.hpp => tcp_server.c} | 0 src/lib/net/tcp_server.h | 16 +++++++++ 6 files changed, 58 insertions(+) rename src/lib/net/{client.cpp => connection.cpp} (100%) create mode 100644 src/lib/net/connection.hpp rename src/lib/net/{client.hpp => tcp_client.c} (100%) rename src/lib/net/{server.cpp => tcp_client.h} (100%) rename src/lib/net/{server.hpp => tcp_server.c} (100%) create mode 100644 src/lib/net/tcp_server.h diff --git a/src/lib/net/client.cpp b/src/lib/net/connection.cpp similarity index 100% rename from src/lib/net/client.cpp rename to src/lib/net/connection.cpp diff --git a/src/lib/net/connection.hpp b/src/lib/net/connection.hpp new file mode 100644 index 0000000..f6cc2d9 --- /dev/null +++ b/src/lib/net/connection.hpp @@ -0,0 +1,42 @@ +// Copyright 2022, FOSS-VG Developers and Contributers +// +// Author(s): +// BodgeMaster +// +// This program is free software: you can redistribute it and/or modify it +// under the terms of the GNU Affero General Public License as published +// by the Free Software Foundation, version 3. +// +// This program 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 Affero General Public License for more details. +// +// You should have received a copy of the GNU Affero General Public License +// version 3 along with this program. +// If not, see https://www.gnu.org/licenses/agpl-3.0.en.html + +#pragma once + +#include + +#include "../error.hpp" + +namespace network { + struct Connection { + } + + // host could be a hostname or address + ErrorOr connect(std::string host); + void disconnect(Connection); + + // start listening for incoming connections + ErrorOrVoid startListening(); + // stop listening for new incoming connections but keep existing + // connections open + void stopListening(); + // stop listening for incoming connections and disconnect all + void stopCommunication(); + + ErrorOr acceptNextIncoming(); +} diff --git a/src/lib/net/client.hpp b/src/lib/net/tcp_client.c similarity index 100% rename from src/lib/net/client.hpp rename to src/lib/net/tcp_client.c diff --git a/src/lib/net/server.cpp b/src/lib/net/tcp_client.h similarity index 100% rename from src/lib/net/server.cpp rename to src/lib/net/tcp_client.h diff --git a/src/lib/net/server.hpp b/src/lib/net/tcp_server.c similarity index 100% rename from src/lib/net/server.hpp rename to src/lib/net/tcp_server.c diff --git a/src/lib/net/tcp_server.h b/src/lib/net/tcp_server.h new file mode 100644 index 0000000..143a4fc --- /dev/null +++ b/src/lib/net/tcp_server.h @@ -0,0 +1,16 @@ +// Copyright 2022, FOSS-VG Developers and Contributers +// +// Author(s): +// +// This program is free software: you can redistribute it and/or modify it +// under the terms of the GNU Affero General Public License as published +// by the Free Software Foundation, version 3. +// +// This program 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 Affero General Public License for more details. +// +// You should have received a copy of the GNU Affero General Public License +// version 3 along with this program. +// If not, see https://www.gnu.org/licenses/agpl-3.0.en.html