Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
C
code
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Container Registry
Model registry
Operate
Environments
Monitor
Incidents
Service Desk
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
ReadMailReallyFast
code
Commits
5b733302
Commit
5b733302
authored
3 years ago
by
Leon Dietrich
Committed by
Benny Baumann
2 years ago
Browse files
Options
Downloads
Patches
Plain Diff
add: Document TCP server class
parent
82f9f817
No related branches found
No related tags found
1 merge request
!1
First unit tests
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
src/net/tcp_server_socket.hpp
+30
-0
30 additions, 0 deletions
src/net/tcp_server_socket.hpp
with
30 additions
and
0 deletions
src/net/tcp_server_socket.hpp
+
30
−
0
View file @
5b733302
...
@@ -17,6 +17,14 @@
...
@@ -17,6 +17,14 @@
namespace
rmrf
::
net
{
namespace
rmrf
::
net
{
/**
* This class awaits incomming TCP connections and submits them to the provided client listener callback.
* @class tcp_server_socket
* @author doralitze
* @date 14/01/21
* @file tcp_server_socket.hpp
* @brief A TCP server delivering incomming connections to you.
*/
class
tcp_server_socket
:
public
std
::
enable_shared_from_this
<
tcp_server_socket
>
{
class
tcp_server_socket
:
public
std
::
enable_shared_from_this
<
tcp_server_socket
>
{
public:
public:
typedef
std
::
function
<
void
(
tcp_client
)
>
incoming_client_listener_type
;
typedef
std
::
function
<
void
(
tcp_client
)
>
incoming_client_listener_type
;
...
@@ -27,8 +35,30 @@ private:
...
@@ -27,8 +35,30 @@ private:
std
::
atomic_uint32_t
number_of_connected_clients
;
std
::
atomic_uint32_t
number_of_connected_clients
;
public:
public:
/**
* This constructor accepts a port to bind to and the client listener that should be called when clients arrive.
* This constructor automatically binds to all avaliable IPv6 interfaces on the specified port.
* @brief Construct a TCP server that listens on all interfaces
* @param port The port to bind to
* @param client_listener_ The client listener to call when a client arrives.
*/
tcp_server_socket
(
const
uint16_t
port
,
incoming_client_listener_type
client_listener_
);
tcp_server_socket
(
const
uint16_t
port
,
incoming_client_listener_type
client_listener_
);
/**
* This constructor accepts an interface description to bind to and the client listener that should be called when clients arrive.
* @brief Construct a TCP server that listens on the specified interface
* @param socket_identifier The socket to bind to
* @param port The port to bind to
* @param client_listener_ The client listener to call when a client arrives.
*/
tcp_server_socket
(
const
socketaddr
&
socket_identifier
,
incoming_client_listener_type
client_listener_
);
tcp_server_socket
(
const
socketaddr
&
socket_identifier
,
incoming_client_listener_type
client_listener_
);
/**
* This method provides you with the current number of connected clients. When a client
* disconnects this number will be reduced. When a new client arrives this number will be incremented.
* @brief Get the current number of connected clients.
* @return The number of connected clients
*/
int
get_number_of_connected_clients
()
const
;
int
get_number_of_connected_clients
()
const
;
private:
private:
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment