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
cbde04d8
Commit
cbde04d8
authored
May 18, 2023
by
Dominik Charousset
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Prefer CAF's own print over sprintf
(cherry picked from commit
b0ec89ec
)
parent
b50e2249
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
4 additions
and
6 deletions
+4
-6
libcaf_io/src/io/network/interfaces.cpp
libcaf_io/src/io/network/interfaces.cpp
+4
-6
No files found.
libcaf_io/src/io/network/interfaces.cpp
View file @
cbde04d8
...
@@ -36,6 +36,7 @@
...
@@ -36,6 +36,7 @@
#include <utility>
#include <utility>
#include "caf/detail/get_mac_addresses.hpp"
#include "caf/detail/get_mac_addresses.hpp"
#include "caf/detail/print.hpp"
#include "caf/io/network/ip_endpoint.hpp"
#include "caf/io/network/ip_endpoint.hpp"
#include "caf/raise_error.hpp"
#include "caf/raise_error.hpp"
...
@@ -262,14 +263,11 @@ interfaces::server_address(uint16_t port, const char* host,
...
@@ -262,14 +263,11 @@ interfaces::server_address(uint16_t port, const char* host,
bool
interfaces
::
get_endpoint
(
const
std
::
string
&
host
,
uint16_t
port
,
bool
interfaces
::
get_endpoint
(
const
std
::
string
&
host
,
uint16_t
port
,
ip_endpoint
&
ep
,
ip_endpoint
&
ep
,
optional
<
protocol
::
network
>
preferred
)
{
optional
<
protocol
::
network
>
preferred
)
{
static_assert
(
sizeof
(
uint16_t
)
==
sizeof
(
unsigned
short
int
),
"uint16_t cannot be printed with %hu in snprintf"
);
addrinfo
hint
;
addrinfo
hint
;
// max port is 2^16 which needs 5 characters plus null terminator
char
port_hint
[
6
];
sprintf
(
port_hint
,
"%hu"
,
port
);
memset
(
&
hint
,
0
,
sizeof
(
hint
));
memset
(
&
hint
,
0
,
sizeof
(
hint
));
hint
.
ai_socktype
=
SOCK_DGRAM
;
hint
.
ai_socktype
=
SOCK_DGRAM
;
std
::
string
port_hint
;
detail
::
print
(
port_hint
,
port
);
if
(
preferred
)
if
(
preferred
)
hint
.
ai_family
=
*
preferred
==
protocol
::
network
::
ipv4
?
AF_INET
:
AF_INET6
;
hint
.
ai_family
=
*
preferred
==
protocol
::
network
::
ipv4
?
AF_INET
:
AF_INET6
;
#ifdef AI_V4MAPPED
#ifdef AI_V4MAPPED
...
@@ -277,7 +275,7 @@ bool interfaces::get_endpoint(const std::string& host, uint16_t port,
...
@@ -277,7 +275,7 @@ bool interfaces::get_endpoint(const std::string& host, uint16_t port,
hint
.
ai_flags
=
AI_V4MAPPED
;
hint
.
ai_flags
=
AI_V4MAPPED
;
#endif
#endif
addrinfo
*
tmp
=
nullptr
;
addrinfo
*
tmp
=
nullptr
;
if
(
getaddrinfo
(
host
.
c_str
(),
port_hint
,
&
hint
,
&
tmp
)
!=
0
)
if
(
getaddrinfo
(
host
.
c_str
(),
port_hint
.
c_str
()
,
&
hint
,
&
tmp
)
!=
0
)
return
false
;
return
false
;
std
::
unique_ptr
<
addrinfo
,
decltype
(
freeaddrinfo
)
*>
addrs
{
tmp
,
freeaddrinfo
};
std
::
unique_ptr
<
addrinfo
,
decltype
(
freeaddrinfo
)
*>
addrs
{
tmp
,
freeaddrinfo
};
for
(
auto
i
=
addrs
.
get
();
i
!=
nullptr
;
i
=
i
->
ai_next
)
{
for
(
auto
i
=
addrs
.
get
();
i
!=
nullptr
;
i
=
i
->
ai_next
)
{
...
...
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