summaryrefslogtreecommitdiffhomepage
path: root/examples/simple_unique_socket
diff options
context:
space:
mode:
authorAmlal El Mahrouss <amlal@nekernel.org>2025-12-04 06:12:03 -0500
committerAmlal El Mahrouss <amlal@nekernel.org>2025-12-04 06:15:20 -0500
commit3c1fec18cc1d11d247cfd0bd23c199ea65f3d7bd (patch)
tree81a7e6bd2264f0e2740a74be05aa708c53f01000 /examples/simple_unique_socket
chore: OCL.FIX module, initial commit.
Signed-off-by: Amlal El Mahrouss <amlal@nekernel.org>
Diffstat (limited to 'examples/simple_unique_socket')
-rw-r--r--examples/simple_unique_socket/CMakeLists.txt15
-rw-r--r--examples/simple_unique_socket/example.cc22
2 files changed, 37 insertions, 0 deletions
diff --git a/examples/simple_unique_socket/CMakeLists.txt b/examples/simple_unique_socket/CMakeLists.txt
new file mode 100644
index 0000000..2cf3648
--- /dev/null
+++ b/examples/simple_unique_socket/CMakeLists.txt
@@ -0,0 +1,15 @@
+
+cmake_minimum_required(VERSION 3.15...3.31)
+
+project(
+ NetworkExample
+ VERSION 1.0
+ LANGUAGES CXX)
+
+find_package(Boost REQUIRED COMPONENTS container)
+
+add_executable(NetworkExample example.cc)
+
+set_property(TARGET NetworkExample PROPERTY CXX_STANDARD 20)
+target_include_directories(NetworkExample PUBLIC ../../include/ocl)
+target_link_libraries(NetworkExample PRIVATE Boost::container)
diff --git a/examples/simple_unique_socket/example.cc b/examples/simple_unique_socket/example.cc
new file mode 100644
index 0000000..b5bd34f
--- /dev/null
+++ b/examples/simple_unique_socket/example.cc
@@ -0,0 +1,22 @@
+#include <ocl/unique_socket.hpp>
+#include <ocl/print.hpp>
+
+/// @brief Basic Send test
+int main()
+{
+ ocl::unique_socket sock = ocl::unique_socket::make_socket<8005>(ocl::unique_socket::any_address, true);
+
+ char buf_dst[512] = {"HELLO, WORLD\0"};
+
+ ocl::unique_socket sock2 = ocl::unique_socket::make_socket<8005>(ocl::unique_socket::any_address, false);
+
+ char buf_dst2[512] = {0};
+
+ auto new_sock = sock.accept();
+ new_sock.write_from_buffer(buf_dst, strlen(buf_dst));
+ sock2.read_client_buffer(buf_dst2, strlen(buf_dst));
+ std::cout << "result:" << buf_dst2 << "\n";
+
+
+ return EXIT_SUCCESS;
+}