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
c0d766d2
Commit
c0d766d2
authored
Oct 24, 2016
by
Joseph Noir
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add some convenience functions
parent
43f9d975
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
34 additions
and
0 deletions
+34
-0
libcaf_io/caf/io/abstract_broker.hpp
libcaf_io/caf/io/abstract_broker.hpp
+11
-0
libcaf_io/src/abstract_broker.cpp
libcaf_io/src/abstract_broker.cpp
+23
-0
No files found.
libcaf_io/caf/io/abstract_broker.hpp
View file @
c0d766d2
...
...
@@ -251,6 +251,17 @@ public:
/// Returns the handle associated to given local `port` or `none`.
accept_handle
hdl_by_port
(
uint16_t
port
);
/// Returns the remote address associated to `hdl`
/// or empty string if `hdl` is invalid.
std
::
string
remote_addr
(
datagram_sink_handle
hdl
);
/// Returns the remote port associated to `hdl`
/// or `0` if `hdl` is invalid.
uint16_t
remote_port
(
datagram_sink_handle
hdl
);
/// Returns the local port associated to `hdl` or `0` if `hdl` is invalid.
uint16_t
local_port
(
datagram_source_handle
hdl
);
/// Closes all connections and acceptors.
void
close_all
();
...
...
libcaf_io/src/abstract_broker.cpp
View file @
c0d766d2
...
...
@@ -230,6 +230,21 @@ uint16_t abstract_broker::local_port(accept_handle hdl) {
return
i
!=
doormen_
.
end
()
?
i
->
second
->
port
()
:
0
;
}
std
::
string
abstract_broker
::
remote_addr
(
datagram_sink_handle
hdl
)
{
auto
i
=
datagram_sinks_
.
find
(
hdl
);
return
i
!=
datagram_sinks_
.
end
()
?
i
->
second
->
addr
()
:
std
::
string
{};
}
uint16_t
abstract_broker
::
remote_port
(
datagram_sink_handle
hdl
)
{
auto
i
=
datagram_sinks_
.
find
(
hdl
);
return
i
!=
datagram_sinks_
.
end
()
?
i
->
second
->
port
()
:
0
;
}
uint16_t
abstract_broker
::
local_port
(
datagram_source_handle
hdl
)
{
auto
i
=
datagram_sources_
.
find
(
hdl
);
return
i
!=
datagram_sources_
.
end
()
?
i
->
second
->
port
()
:
0
;
}
accept_handle
abstract_broker
::
hdl_by_port
(
uint16_t
port
)
{
for
(
auto
&
kvp
:
doormen_
)
if
(
kvp
.
second
->
port
()
==
port
)
...
...
@@ -247,6 +262,14 @@ void abstract_broker::close_all() {
// stop_reading will remove the scribe from scribes_
scribes_
.
begin
()
->
second
->
stop_reading
();
}
while
(
!
datagram_sinks_
.
empty
())
{
// stop_reading will remove the datagram_sink from datagram_sinks_
datagram_sinks_
.
begin
()
->
second
->
stop_reading
();
}
while
(
!
datagram_sources_
.
empty
())
{
// stop_reading will remove the datgram_source from datgram_sources_
datagram_sources_
.
begin
()
->
second
->
stop_reading
();
}
}
resumable
::
subtype_t
abstract_broker
::
subtype
()
const
{
...
...
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