Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
A
actor-incubator
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
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-incubator
Commits
41311fa2
Commit
41311fa2
authored
Aug 27, 2019
by
Jakob Otto
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fix test on Linux
parent
b563087b
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
13 additions
and
7 deletions
+13
-7
libcaf_net/caf/net/udp_datagram_socket.hpp
libcaf_net/caf/net/udp_datagram_socket.hpp
+4
-2
libcaf_net/src/udp_datagram_socket.cpp
libcaf_net/src/udp_datagram_socket.cpp
+5
-2
libcaf_net/test/udp_datagram_socket.cpp
libcaf_net/test/udp_datagram_socket.cpp
+4
-3
No files found.
libcaf_net/caf/net/udp_datagram_socket.hpp
View file @
41311fa2
...
@@ -42,7 +42,7 @@ struct udp_datagram_socket : abstract_socket<udp_datagram_socket> {
...
@@ -42,7 +42,7 @@ struct udp_datagram_socket : abstract_socket<udp_datagram_socket> {
};
};
/// Enables or disables `SIO_UDP_CONNRESET` error on `x`.
/// Enables or disables `SIO_UDP_CONNRESET` error on `x`.
/// @relates datagram_socket
/// @relates
udp_
datagram_socket
error
allow_connreset
(
udp_datagram_socket
x
,
bool
new_value
);
error
allow_connreset
(
udp_datagram_socket
x
,
bool
new_value
);
/// Receives data from `x`.
/// Receives data from `x`.
...
@@ -68,7 +68,9 @@ variant<size_t, sec> write(udp_datagram_socket x, span<const byte> buf,
...
@@ -68,7 +68,9 @@ variant<size_t, sec> write(udp_datagram_socket x, span<const byte> buf,
/// Binds given socket to given ip_endpoint.
/// Binds given socket to given ip_endpoint.
/// @param x the socket that should be bound.
/// @param x the socket that should be bound.
/// @param ep the endpoint to which the socket should be bound.
/// @param ep the endpoint to which the socket should be bound.
error
bind
(
udp_datagram_socket
x
,
ip_endpoint
ep
);
/// @returns The port that was actually bound.
/// @Relates udp_datagram_socket
expected
<
uint16_t
>
bind
(
udp_datagram_socket
x
,
ip_endpoint
ep
);
/// Converts the result from I/O operation on a ::udp_datagram_socket to either
/// Converts the result from I/O operation on a ::udp_datagram_socket to either
/// an error code or a non-zero positive integer.
/// an error code or a non-zero positive integer.
...
...
libcaf_net/src/udp_datagram_socket.cpp
View file @
41311fa2
...
@@ -89,12 +89,15 @@ variant<size_t, sec> write(udp_datagram_socket x, span<const byte> buf,
...
@@ -89,12 +89,15 @@ variant<size_t, sec> write(udp_datagram_socket x, span<const byte> buf,
return
get
<
sec
>
(
ret
);
return
get
<
sec
>
(
ret
);
}
}
e
rror
bind
(
udp_datagram_socket
x
,
ip_endpoint
ep
)
{
e
xpected
<
uint16_t
>
bind
(
udp_datagram_socket
x
,
ip_endpoint
ep
)
{
auto
addr
=
to_sockaddr
(
ep
);
auto
addr
=
to_sockaddr
(
ep
);
CAF_NET_SYSCALL
(
"bind"
,
err
,
!=
,
0
,
CAF_NET_SYSCALL
(
"bind"
,
err
,
!=
,
0
,
::
bind
(
x
.
id
,
reinterpret_cast
<
sockaddr
*>
(
&
addr
),
::
bind
(
x
.
id
,
reinterpret_cast
<
sockaddr
*>
(
&
addr
),
sizeof
(
sockaddr_in6
)));
sizeof
(
sockaddr_in6
)));
return
none
;
socklen_t
len
=
sizeof
(
sockaddr_in6
);
CAF_NET_SYSCALL
(
"getsockname"
,
erro
,
!=
,
0
,
getsockname
(
x
.
id
,
reinterpret_cast
<
sockaddr
*>
(
&
addr
),
&
len
));
return
addr
.
sin6_port
;
}
}
variant
<
size_t
,
sec
>
variant
<
size_t
,
sec
>
...
...
libcaf_net/test/udp_datagram_socket.cpp
View file @
41311fa2
...
@@ -53,7 +53,7 @@ CAF_TEST_FIXTURE_SCOPE(udp_datagram_socket_test, fixture)
...
@@ -53,7 +53,7 @@ CAF_TEST_FIXTURE_SCOPE(udp_datagram_socket_test, fixture)
CAF_TEST
(
send
and
receive
)
{
CAF_TEST
(
send
and
receive
)
{
std
::
vector
<
byte
>
buf
(
1024
);
std
::
vector
<
byte
>
buf
(
1024
);
ip_endpoint
ep
;
ip_endpoint
ep
;
if
(
auto
err
=
detail
::
parse
(
"[::1]:
55555
"
,
ep
))
if
(
auto
err
=
detail
::
parse
(
"[::1]:
0
"
,
ep
))
CAF_FAIL
(
"unable to parse input: "
<<
err
);
CAF_FAIL
(
"unable to parse input: "
<<
err
);
auto
sender
=
unbox
(
make_socket
());
auto
sender
=
unbox
(
make_socket
());
auto
receiver
=
unbox
(
make_socket
());
auto
receiver
=
unbox
(
make_socket
());
...
@@ -61,8 +61,9 @@ CAF_TEST(send and receive) {
...
@@ -61,8 +61,9 @@ CAF_TEST(send and receive) {
close
(
socket_cast
<
net
::
socket
>
(
sender
));
close
(
socket_cast
<
net
::
socket
>
(
sender
));
close
(
socket_cast
<
net
::
socket
>
(
receiver
));
close
(
socket_cast
<
net
::
socket
>
(
receiver
));
});
});
if
(
auto
err
=
bind
(
receiver
,
ep
))
auto
port
=
unbox
(
bind
(
receiver
,
ep
));
CAF_FAIL
(
"unable to bind socket"
<<
err
);
CAF_MESSAGE
(
"socket bound to port "
<<
port
);
ep
.
port
(
htons
(
port
));
if
(
nonblocking
(
socket_cast
<
net
::
socket
>
(
receiver
),
true
))
if
(
nonblocking
(
socket_cast
<
net
::
socket
>
(
receiver
),
true
))
CAF_FAIL
(
"nonblocking failed"
);
CAF_FAIL
(
"nonblocking failed"
);
auto
test_read_res
=
read
(
receiver
,
make_span
(
buf
));
auto
test_read_res
=
read
(
receiver
,
make_span
(
buf
));
...
...
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