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
2e367398
Commit
2e367398
authored
Jul 10, 2019
by
Dominik Charousset
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add new interface for socket managers
parent
6ae9f8d0
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
104 additions
and
0 deletions
+104
-0
libcaf_net/CMakeLists.txt
libcaf_net/CMakeLists.txt
+1
-0
libcaf_net/caf/net/socket_manager.hpp
libcaf_net/caf/net/socket_manager.hpp
+68
-0
libcaf_net/src/socket_manager.cpp
libcaf_net/src/socket_manager.cpp
+35
-0
No files found.
libcaf_net/CMakeLists.txt
View file @
2e367398
...
...
@@ -11,6 +11,7 @@ set(LIBCAF_NET_SRCS
src/network_socket.cpp
src/pipe_socket.cpp
src/socket.cpp
src/socket_manager.cpp
)
add_custom_target
(
libcaf_net
)
...
...
libcaf_net/caf/net/socket_manager.hpp
0 → 100644
View file @
2e367398
/******************************************************************************
* ____ _ _____ *
* / ___| / \ | ___| C++ *
* | | / _ \ | |_ Actor *
* | |___ / ___ \| _| Framework *
* \____/_/ \_|_| *
* *
* Copyright 2011-2019 Dominik Charousset *
* *
* Distributed under the terms and conditions of the BSD 3-Clause License or *
* (at your option) under the terms and conditions of the Boost Software *
* License 1.0. See accompanying files LICENSE and LICENSE_ALTERNATIVE. *
* *
* If you did not receive a copy of the license files, see *
* http://opensource.org/licenses/BSD-3-Clause and *
* http://www.boost.org/LICENSE_1_0.txt. *
******************************************************************************/
#pragma once
#include "caf/error.hpp"
#include "caf/net/socket.hpp"
namespace
caf
{
namespace
net
{
/// Manages the lifetime of a single socket and handles any I/O events on it.
class
socket_manager
{
public:
// -- constructors, destructors, and assignment operators --------------------
explicit
socket_manager
(
socket
handle
);
virtual
~
socket_manager
();
socket_manager
(
const
socket_manager
&
)
=
delete
;
socket_manager
&
operator
=
(
const
socket_manager
&
)
=
delete
;
// -- properties -------------------------------------------------------------
socket
handle
()
const
noexcept
{
return
handle_
;
}
// -- pure virtual member functions ------------------------------------------
/// Called whenever the socket received new data.
virtual
error
handle_read_event
()
=
0
;
/// Called whenever the socket is allowed to send additional data.
virtual
error
handle_write_event
()
=
0
;
/// Called if the remote side becomes unreachable.
/// @param reason A default-constructed error object (no error) if the remote
/// host performed an ordinary shutdown (only for connection
/// oriented sockets), otherwise an error code as reported by
/// the operating system.
virtual
void
handle_shutdown_event
(
error
reason
)
=
0
;
private:
// -- member variables -------------------------------------------------------
socket
handle_
;
};
}
// namespace net
}
// namespace caf
libcaf_net/src/socket_manager.cpp
0 → 100644
View file @
2e367398
/******************************************************************************
* ____ _ _____ *
* / ___| / \ | ___| C++ *
* | | / _ \ | |_ Actor *
* | |___ / ___ \| _| Framework *
* \____/_/ \_|_| *
* *
* Copyright 2011-2019 Dominik Charousset *
* *
* Distributed under the terms and conditions of the BSD 3-Clause License or *
* (at your option) under the terms and conditions of the Boost Software *
* License 1.0. See accompanying files LICENSE and LICENSE_ALTERNATIVE. *
* *
* If you did not receive a copy of the license files, see *
* http://opensource.org/licenses/BSD-3-Clause and *
* http://www.boost.org/LICENSE_1_0.txt. *
******************************************************************************/
#include "caf/net/socket_manager.hpp"
#include "caf/config.hpp"
namespace
caf
{
namespace
net
{
socket_manager
::
socket_manager
(
socket
handle
)
:
handle_
(
handle
)
{
CAF_ASSERT
(
handle
!=
invalid_socket
);
}
socket_manager
::~
socket_manager
()
{
close
(
handle_
);
}
}
// namespace net
}
// namespace caf
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