Orbit Framework
An ultra-modern, asynchronous, cross-platform C++ Web Framework.
Loading...
Searching...
No Matches
Socket.hpp
Go to the documentation of this file.
1#pragma once
3
4namespace network {
5
6class Socket {
7public:
8 // Create a new socket
9 Socket();
10
11 // Wrap an existing socket file descriptor
12 explicit Socket(socket_t fd);
13
14 // Destructor: Closes the socket to prevent leaks (RAII)
15 ~Socket();
16
17 // Delete copy semantics to prevent double-closing
18 Socket(const Socket&) = delete;
19 Socket& operator=(const Socket&) = delete;
20
21 // Allow move semantics
22 Socket(Socket&& other) noexcept;
23 Socket& operator=(Socket&& other) noexcept;
24
25 socket_t fd() const;
26 bool is_valid() const;
27 void close();
28
29 // Convert socket to non-blocking mode
30 void set_non_blocking();
31
32private:
33 socket_t fd_;
34};
35
36} // namespace network
Definition Socket.hpp:6
~Socket()
Definition Socket.cpp:18
Socket()
Definition Socket.cpp:9
Socket & operator=(const Socket &)=delete
void set_non_blocking()
Definition Socket.cpp:50
void close()
Definition Socket.cpp:43
bool is_valid() const
Definition Socket.cpp:39
socket_t fd() const
Definition Socket.cpp:35
Socket(const Socket &)=delete
Definition ResponseWriter.hpp:7
int socket_t
Definition PlatformSocket.hpp:36