Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
M
mpd
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Registry
Registry
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Иван Мажукин
mpd
Commits
1f47dc99
Commit
1f47dc99
authored
Aug 10, 2017
by
Max Kellermann
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
net/SocketDescriptor: add method SetKeepAlive()
parent
9a5bcc6d
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
8 additions
and
13 deletions
+8
-13
ServerSocket.cxx
src/event/ServerSocket.cxx
+1
-1
SocketDescriptor.cxx
src/net/SocketDescriptor.cxx
+6
-0
SocketDescriptor.hxx
src/net/SocketDescriptor.hxx
+1
-0
SocketUtil.cxx
src/net/SocketUtil.cxx
+0
-9
SocketUtil.hxx
src/net/SocketUtil.hxx
+0
-3
No files found.
src/event/ServerSocket.cxx
View file @
1f47dc99
...
...
@@ -158,7 +158,7 @@ OneServerSocket::Accept() noexcept
return
;
}
if
(
socket_keepalive
(
peer_fd
.
Get
()
))
{
if
(
!
peer_fd
.
SetKeepAlive
(
))
{
const
SocketErrorMessage
msg
;
FormatError
(
server_socket_domain
,
"Could not set TCP keepalive option: %s"
,
...
...
src/net/SocketDescriptor.cxx
View file @
1f47dc99
...
...
@@ -207,6 +207,12 @@ SocketDescriptor::SetOption(int level, int name,
}
bool
SocketDescriptor
::
SetKeepAlive
(
bool
value
)
{
return
SetBoolOption
(
SOL_SOCKET
,
SO_KEEPALIVE
,
value
);
}
bool
SocketDescriptor
::
SetReuseAddress
(
bool
value
)
{
return
SetBoolOption
(
SOL_SOCKET
,
SO_REUSEADDR
,
value
);
...
...
src/net/SocketDescriptor.hxx
View file @
1f47dc99
...
...
@@ -141,6 +141,7 @@ public:
return
SetOption
(
level
,
name
,
&
value
,
sizeof
(
value
));
}
bool
SetKeepAlive
(
bool
value
=
true
);
bool
SetReuseAddress
(
bool
value
=
true
);
#ifdef __linux__
...
...
src/net/SocketUtil.cxx
View file @
1f47dc99
...
...
@@ -49,12 +49,3 @@ socket_bind_listen(int domain, int type, int protocol,
return
fd
;
}
int
socket_keepalive
(
int
fd
)
{
const
int
reuse
=
1
;
return
setsockopt
(
fd
,
SOL_SOCKET
,
SO_KEEPALIVE
,
(
const
char
*
)
&
reuse
,
sizeof
(
reuse
));
}
src/net/SocketUtil.hxx
View file @
1f47dc99
...
...
@@ -49,7 +49,4 @@ socket_bind_listen(int domain, int type, int protocol,
SocketAddress
address
,
int
backlog
);
int
socket_keepalive
(
int
fd
);
#endif
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