Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
A
Actor Framework
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Operations
Operations
Metrics
Environments
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
cpp-libs
Actor Framework
Commits
c83b660c
Commit
c83b660c
authored
Jun 20, 2019
by
Joseph Noir
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Set SO_KEEPALIVE on TCP connections
parent
40e7b16e
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
22 additions
and
0 deletions
+22
-0
libcaf_io/caf/io/network/native_socket.hpp
libcaf_io/caf/io/network/native_socket.hpp
+3
-0
libcaf_io/src/default_multiplexer.cpp
libcaf_io/src/default_multiplexer.cpp
+1
-0
libcaf_io/src/native_socket.cpp
libcaf_io/src/native_socket.cpp
+18
-0
No files found.
libcaf_io/caf/io/network/native_socket.hpp
View file @
c83b660c
...
...
@@ -91,6 +91,9 @@ std::pair<native_socket, native_socket> create_pipe();
/// throws `network_error` on error
expected
<
void
>
child_process_inherit
(
native_socket
fd
,
bool
new_value
);
/// Enables keepalive on `fd`. Throws `network_error` on error.
expected
<
void
>
keepalive
(
native_socket
fd
,
bool
new_value
);
/// Sets fd to nonblocking if `set_nonblocking == true`
/// or to blocking if `set_nonblocking == false`
/// throws `network_error` on error
...
...
libcaf_io/src/default_multiplexer.cpp
View file @
c83b660c
...
...
@@ -672,6 +672,7 @@ void default_multiplexer::exec_later(resumable* ptr) {
scribe_ptr
default_multiplexer
::
new_scribe
(
native_socket
fd
)
{
CAF_LOG_TRACE
(
""
);
keepalive
(
fd
,
true
);
return
make_counted
<
scribe_impl
>
(
*
this
,
fd
);
}
...
...
libcaf_io/src/native_socket.cpp
View file @
c83b660c
...
...
@@ -139,6 +139,15 @@ namespace network {
CALL_CFUN
(
set_res
,
detail
::
cc_not_minus1
,
"fcntl"
,
fcntl
(
fd
,
F_SETFD
,
wf
));
return
unit
;
}
expected
<
void
>
keepalive
(
native_socket
fd
,
bool
new_value
)
{
CAF_LOG_TRACE
(
CAF_ARG
(
fd
)
<<
CAF_ARG
(
new_value
));
int
value
=
new_value
?
1
:
0
;
CALL_CFUN
(
res
,
detail
::
cc_zero
,
"setsockopt"
,
setsockopt
(
fd
,
SOL_SOCKET
,
SO_KEEPALIVE
,
&
value
,
static_cast
<
unsigned
>
(
sizeof
(
value
))));
return
unit
;
}
expected
<
void
>
nonblocking
(
native_socket
fd
,
bool
new_value
)
{
CAF_LOG_TRACE
(
CAF_ARG
(
fd
)
<<
CAF_ARG
(
new_value
));
...
...
@@ -222,6 +231,15 @@ namespace network {
// nop; FIXME: possible to implement via SetHandleInformation ?
return
unit
;
}
expected
<
void
>
keepalive
(
native_socket
fd
,
bool
new_value
)
{
CAF_LOG_TRACE
(
CAF_ARG
(
fd
)
<<
CAF_ARG
(
new_value
));
char
=
new_value
?
1
:
0
;
CALL_CFUN
(
res
,
detail
::
cc_zero
,
"setsockopt"
,
setsockopt
(
fd
,
SOL_SOCKET
,
SO_KEEPALIVE
,
&
value
,
static_cast
<
int
>
(
sizeof
(
value
))));
return
unit
;
}
expected
<
void
>
nonblocking
(
native_socket
fd
,
bool
new_value
)
{
u_long
mode
=
new_value
?
1
:
0
;
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment