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