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
e3f72b4d
Commit
e3f72b4d
authored
2 years ago
by
Benny Baumann
Browse files
Options
Downloads
Patches
Plain Diff
chg: Handle all protocol variants for incoming client connections
parent
c8bbd484
No related branches found
Branches containing commit
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.cpp
+4
-6
4 additions, 6 deletions
src/net/tcp_server_socket.cpp
with
4 additions
and
6 deletions
src/net/tcp_server_socket.cpp
+
4
−
6
View file @
e3f72b4d
...
...
@@ -97,9 +97,10 @@ void tcp_server_socket::await_raw_socket_incomming(
)
{
MARK_UNUSED
(
ass
);
struct
sockaddr_
in
client_addr
;
struct
sockaddr_
storage
client_addr
;
socklen_t
client_len
=
sizeof
(
client_addr
);
int
client_fd_raw
=
accept
(
socket
.
get
(),
(
struct
sockaddr
*
)
&
client_addr
,
&
client_len
);
socketaddr
address
{
client_addr
};
if
(
client_fd_raw
<
0
)
{
throw
netio_exception
(
"Unable to bind incoming client"
);
...
...
@@ -113,9 +114,6 @@ void tcp_server_socket::await_raw_socket_incomming(
throw
netio_exception
(
"Failed to set socket mode. fcntl resulted in error:"
+
std
::
to_string
(
errno
));
}
const
std
::
string
address
=
inet_ntoa
(
client_addr
.
sin_addr
);
const
uint16_t
port
=
ntohs
(
client_addr
.
sin_port
);
// Generate client object from fd and announce it
this
->
number_of_connected_clients
++
;
using
namespace
std
::
placeholders
;
...
...
@@ -129,10 +127,10 @@ void tcp_server_socket::await_raw_socket_incomming(
}
if
(
this
->
max_number_of_simulataneusly_allowed_clients
==
0
||
this
->
get_number_of_connected_clients
()
<=
this
->
max_number_of_simulataneusly_allowed_clients
)
{
this
->
client_listener
(
tcp_client
(
std
::
bind
(
&
tcp_server_socket
::
client_destructed_cb
,
this
,
_1
),
auto_fd
(
client_fd_raw
),
address
,
port
));
this
->
client_listener
(
tcp_client
(
std
::
bind
(
&
tcp_server_socket
::
client_destructed_cb
,
this
,
_1
),
auto_fd
(
client_fd_raw
),
address
));
}
else
{
if
(
this
->
overflow_client_listener
!=
nullptr
)
{
this
->
overflow_client_listener
(
tcp_client
(
std
::
bind
(
&
tcp_server_socket
::
client_destructed_cb
,
this
,
_1
),
auto_fd
(
client_fd_raw
),
address
,
port
));
this
->
overflow_client_listener
(
tcp_client
(
std
::
bind
(
&
tcp_server_socket
::
client_destructed_cb
,
this
,
_1
),
auto_fd
(
client_fd_raw
),
address
));
}
}
}
...
...
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