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
41957aa3
Commit
41957aa3
authored
Jan 15, 2015
by
Marian Triebe
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add support for dualstack IPv6
Closes #174, closes #156
parent
57ca0479
Changes
5
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
225 additions
and
87 deletions
+225
-87
libcaf_io/caf/io/network/default_multiplexer.hpp
libcaf_io/caf/io/network/default_multiplexer.hpp
+20
-33
libcaf_io/caf/io/network/interfaces.hpp
libcaf_io/caf/io/network/interfaces.hpp
+8
-0
libcaf_io/src/default_multiplexer.cpp
libcaf_io/src/default_multiplexer.cpp
+162
-53
libcaf_io/src/interfaces.cpp
libcaf_io/src/interfaces.cpp
+34
-1
unit_testing/test_unpublish.cpp
unit_testing/test_unpublish.cpp
+1
-0
No files found.
libcaf_io/caf/io/network/default_multiplexer.hpp
View file @
41957aa3
...
@@ -419,7 +419,6 @@ class default_multiplexer : public multiplexer {
...
@@ -419,7 +419,6 @@ class default_multiplexer : public multiplexer {
std
::
pair
<
native_socket
,
native_socket
>
m_pipe
;
std
::
pair
<
native_socket
,
native_socket
>
m_pipe
;
std
::
thread
::
id
m_tid
;
std
::
thread
::
id
m_tid
;
};
};
default_multiplexer
&
get_multiplexer_singleton
();
default_multiplexer
&
get_multiplexer_singleton
();
...
@@ -658,20 +657,20 @@ class stream : public event_handler {
...
@@ -658,20 +657,20 @@ class stream : public event_handler {
}
}
// reading & writing
// reading & writing
Socket
m_sock
;
Socket
m_sock
;
// reading
// reading
manager_ptr
m_reader
;
manager_ptr
m_reader
;
size_t
m_threshold
;
size_t
m_threshold
;
size_t
m_collected
;
size_t
m_collected
;
size_t
m_max
;
size_t
m_max
;
receive_policy_flag
m_rd_flag
;
receive_policy_flag
m_rd_flag
;
buffer_type
m_rd_buf
;
buffer_type
m_rd_buf
;
// writing
// writing
manager_ptr
m_writer
;
manager_ptr
m_writer
;
bool
m_writing
;
bool
m_writing
;
size_t
m_written
;
size_t
m_written
;
buffer_type
m_wr_buf
;
buffer_type
m_wr_buf
;
buffer_type
m_wr_offline_buf
;
buffer_type
m_wr_offline_buf
;
};
};
/**
/**
...
@@ -763,7 +762,9 @@ class acceptor : public event_handler {
...
@@ -763,7 +762,9 @@ class acceptor : public event_handler {
void
removed_from_loop
(
operation
op
)
override
{
void
removed_from_loop
(
operation
op
)
override
{
CAF_LOG_TRACE
(
"m_accept_sock.fd = "
<<
m_accept_sock
.
fd
()
CAF_LOG_TRACE
(
"m_accept_sock.fd = "
<<
m_accept_sock
.
fd
()
<<
"op = "
<<
static_cast
<
int
>
(
op
));
<<
"op = "
<<
static_cast
<
int
>
(
op
));
if
(
op
==
operation
::
read
)
m_mgr
.
reset
();
if
(
op
==
operation
::
read
)
{
m_mgr
.
reset
();
}
}
}
protected:
protected:
...
@@ -780,31 +781,17 @@ class acceptor : public event_handler {
...
@@ -780,31 +781,17 @@ class acceptor : public event_handler {
};
};
native_socket
new_ipv4_connection_impl
(
const
std
::
string
&
,
uint16_t
);
native_socket
new_tcp_connection_impl
(
const
std
::
string
&
,
uint16_t
,
optional
<
protocol
>
preferred
=
none
);
default_socket
new_ipv4_connection
(
const
std
::
string
&
host
,
uint16_t
port
);
default_socket
new_tcp_connection
(
const
std
::
string
&
host
,
uint16_t
port
);
template
<
class
Socket
>
void
ipv4_connect
(
Socket
&
sock
,
const
std
::
string
&
host
,
uint16_t
port
)
{
sock
=
new_ipv4_connection
(
host
,
port
);
}
std
::
pair
<
native_socket
,
uint16_t
>
std
::
pair
<
native_socket
,
uint16_t
>
new_
ipv4
_acceptor_impl
(
uint16_t
port
,
const
char
*
addr
,
bool
reuse_addr
);
new_
tcp
_acceptor_impl
(
uint16_t
port
,
const
char
*
addr
,
bool
reuse_addr
);
std
::
pair
<
default_socket_acceptor
,
uint16_t
>
std
::
pair
<
default_socket_acceptor
,
uint16_t
>
new_ipv4_acceptor
(
uint16_t
port
,
const
char
*
addr
=
nullptr
,
new_tcp_acceptor
(
uint16_t
port
,
const
char
*
addr
=
nullptr
,
bool
reuse_addr
=
false
);
bool
reuse_addr
=
false
);
template
<
class
SocketAcceptor
>
uint16_t
ipv4_bind
(
SocketAcceptor
&
sock
,
uint16_t
port
,
const
char
*
addr
=
nullptr
)
{
CAF_LOGF_TRACE
(
CAF_ARG
(
port
));
auto
acceptor
=
new_ipv4_acceptor
(
port
,
addr
);
sock
=
std
::
move
(
acceptor
.
first
);
return
acceptor
.
second
;
}
}
// namespace network
}
// namespace network
}
// namespace io
}
// namespace io
...
...
libcaf_io/caf/io/network/interfaces.hpp
View file @
41957aa3
...
@@ -25,6 +25,8 @@
...
@@ -25,6 +25,8 @@
#include <string>
#include <string>
#include <utility>
#include <utility>
#include "caf/optional.hpp"
#include "caf/io/network/protocol.hpp"
#include "caf/io/network/protocol.hpp"
namespace
caf
{
namespace
caf
{
...
@@ -57,6 +59,12 @@ class interfaces {
...
@@ -57,6 +59,12 @@ class interfaces {
*/
*/
static
std
::
vector
<
std
::
string
>
list_addresses
(
protocol
proc
,
static
std
::
vector
<
std
::
string
>
list_addresses
(
protocol
proc
,
bool
include_localhost
=
true
);
bool
include_localhost
=
true
);
/**
* Returns `pair<string, protocol>` for given host address.
**/
static
optional
<
std
::
pair
<
std
::
string
,
protocol
>>
get_addrinfo_of_host
(
const
std
::
string
&
host
,
optional
<
protocol
>
preferred
=
none
);
};
};
}
// namespace network
}
// namespace network
...
...
libcaf_io/src/default_multiplexer.cpp
View file @
41957aa3
This diff is collapsed.
Click to expand it.
libcaf_io/src/interfaces.cpp
View file @
41957aa3
...
@@ -19,8 +19,8 @@
...
@@ -19,8 +19,8 @@
#include "caf/io/network/interfaces.hpp"
#include "caf/io/network/interfaces.hpp"
#include <errno.h>
#include <netdb.h>
#include <netdb.h>
#include <errno.h>
#include <stdlib.h>
#include <stdlib.h>
#include <string.h>
#include <string.h>
#include <net/if.h>
#include <net/if.h>
...
@@ -144,6 +144,39 @@ std::vector<std::string> interfaces::list_addresses(protocol proc,
...
@@ -144,6 +144,39 @@ std::vector<std::string> interfaces::list_addresses(protocol proc,
return
result
;
return
result
;
}
}
optional
<
std
::
pair
<
std
::
string
,
protocol
>>
interfaces
::
get_addrinfo_of_host
(
const
std
::
string
&
host
,
optional
<
protocol
>
preferred
)
{
addrinfo
hint
;
memset
(
&
hint
,
0
,
sizeof
(
hint
));
hint
.
ai_socktype
=
SOCK_STREAM
;
if
(
preferred
)
{
hint
.
ai_family
=
*
preferred
==
protocol
::
ipv4
?
AF_INET
:
AF_INET6
;
}
addrinfo
*
tmp
=
nullptr
;
if
(
getaddrinfo
(
host
.
c_str
(),
nullptr
,
&
hint
,
&
tmp
))
{
return
none
;
}
std
::
unique_ptr
<
addrinfo
,
decltype
(
freeaddrinfo
)
*>
addrs
{
tmp
,
freeaddrinfo
};
for
(
auto
i
=
addrs
.
get
();
i
!=
nullptr
;
i
=
i
->
ai_next
)
{
auto
family
=
i
->
ai_family
;
if
(
family
==
AF_INET
||
family
==
AF_INET6
)
{
char
buffer
[
INET6_ADDRSTRLEN
];
auto
res
=
family
==
AF_INET
?
inet_ntop
(
family
,
&
reinterpret_cast
<
sockaddr_in
*>
(
i
->
ai_addr
)
->
sin_addr
,
buffer
,
sizeof
(
buffer
))
:
inet_ntop
(
family
,
&
reinterpret_cast
<
sockaddr_in6
*>
(
i
->
ai_addr
)
->
sin6_addr
,
buffer
,
sizeof
(
buffer
));
if
(
res
!=
nullptr
)
{
return
{{
res
,
family
==
AF_INET
?
protocol
::
ipv4
:
protocol
::
ipv6
}};
}
}
}
return
none
;
}
}
// namespace network
}
// namespace network
}
// namespace io
}
// namespace io
}
// namespace caf
}
// namespace caf
unit_testing/test_unpublish.cpp
View file @
41957aa3
...
@@ -65,6 +65,7 @@ int main() {
...
@@ -65,6 +65,7 @@ int main() {
auto
port
=
publish_at_some_port
(
4242
,
d
);
auto
port
=
publish_at_some_port
(
4242
,
d
);
std
::
this_thread
::
sleep_for
(
std
::
chrono
::
milliseconds
(
50
));
std
::
this_thread
::
sleep_for
(
std
::
chrono
::
milliseconds
(
50
));
io
::
unpublish
(
d
,
port
);
io
::
unpublish
(
d
,
port
);
CAF_CHECKPOINT
();
// must fail now
// must fail now
try
{
try
{
auto
oops
=
io
::
remote_actor
(
"127.0.0.1"
,
port
);
auto
oops
=
io
::
remote_actor
(
"127.0.0.1"
,
port
);
...
...
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